Skip to content

Quick Start

For compatibility reasons, OpenDataSky uses OpenAI's API format to call models. You can use the OpenAI SDK or other OpenAI-compatible interfaces.

Install OpenAI SDK

Please ensure you have a Python environment installed. Use the following command to install the latest OpenAI SDK.

shell
pip install openai
shell
npm install openai

Example

Before calling the API, you need to register with OpenDataSky and create an API Key. You also need to set the base_url to http://server.opendatasky.com/v1/api/open-ai/ds.

The following is an example of a non-streaming call output. You can set stream to true to use streaming output.

python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="http://server.opendatasky.com/v1/api/open-ai/ds"
)

completion = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ],
    top_p=0.7,
    temperature=0.9
)

print(completion.choices[0].message)