Getting Started
Get integrated in three steps.
Endpoints
- API Base URL:
$URL(your API endpoint domain — differs between China and Global environments; use the address assigned to your environment) - Console:
$CONSOLE_URL(for creating tokens and viewing usage)
In all examples below, $URL refers to your API base URL.
1. Get an API Key
- Log in to the Console ($CONSOLE_URL)
- Go to "Token Management" and click "Create Token"
- Copy the generated Key (format
sk-xxxx) and keep it safe
Note
An API Key is equivalent to your account credential. Do not write it into frontend code or public repositories. If leaked, delete and recreate it in the console immediately.
2. Make Your First Request
Here is an example using the chat completions endpoint (OpenAI-compatible format):
bash
curl $URL/v1/chat/completions \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello"}]
}'python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="$URL/v1",
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)ts
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.YOUR_API_KEY,
baseURL: '$URL/v1',
})
const resp = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello' }],
})
console.log(resp.choices[0].message.content)3. Check Usage
Every call's model, token count and cost can be viewed in real time on the "Logs" page of the Console ($CONSOLE_URL).
Next Steps
- Text Generation API: GPT, Claude, DeepSeek, Gemini, GLM and more
- Image Generation API: GPT-Image, Gemini Image
- Video Generation API: Seedance 2.0, Seedance V3, Kling and more, plus two asset libraries (
/v1/assets,/v3/assets) - Error Codes: Troubleshoot calls
