API documentation v1.0

AI model API documentation

This platform provides an OpenAI compatible API. Simply point base_url to this platform to access 50+ leading models without changing your business code.

Core features

Compatibility
OpenAI compatible

Works with the OpenAI SDK; change one configuration line to connect.

Coverage
50+ leading models

Includes DeepSeek, Qwen, kimi and doubao.

Stability
99.9% availability

Multi-node load balancing with automatic failover.

Billing
Pay as you go

Official pricing, no markup. Top up and start using.

API basics

ItemDescription
Base URLhttps://YOUR_DOMAIN/v1
AuthenticationBearer Token in the request header Authorization: Bearer YOUR_API_KEY
Data formatJSON, UTF-8 encoding
ProtocolHTTPS
💡 Tip:Create and view your API Key in Console → API Key management.
Getting started

Get started in 5 minutes

Follow these steps to connect and send your first request in 5 minutes.

Step 1 — Get an API Key

Log in to the console and open API Key management . Click “Create API Key” and copy the generated Key.

Step 2 — Choose a model ID

Open Model hub to view available models and note the desired model_id(e.g. gpt-4o、deepseek-chat)。

Step 3 — Send your first request

cURL
Python
Node.js
# Replace YOUR_API_KEY and DOMAIN
curl https://DOMAIN/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello, introduce yourself"}]
  }'
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://DOMAIN/v1"
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello, introduce yourself"}]
)
print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://DOMAIN/v1",
});

const res = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Hello, introduce yourself" }],
});
console.log(res.choices[0].message.content);
Model list

Supported models

We continually add leading models. Here are some popular choices; see the Model hub in the console for the full list.

Loading models…
More models are being added. Visit the Model hub in the console for the latest list and pricing.
API reference

Text generation · Chat Completions

Given a conversation history, the model generates the next message. This is the core and most widely used endpoint.

Endpoint

POST /v1/chat/completions Create a chat completion

Request parameters

ParameterTypeRequired?Description
modelstringRequiredModel ID, e.g. gpt-4o、deepseek-chat
messagesarrayRequiredA list of messages, each containing role(system/user/assistant) and content
streambooleanOptionalWhether to stream the response; default: false
max_tokensintegerOptionalMaximum number of generated Tokens
temperaturenumberOptionalSampling temperature: 0–2, default 1.0. Lower is more deterministic; higher is more random.
top_pnumberOptionalNucleus sampling: 0–1, default 1.0
nintegerOptionalNumber of candidates; default: 1
stopstring/arrayOptionalStop sequences

Response structure

200 Successful response
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1711900000,
  "model": "gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I am an AI assistant..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 48,
    "total_tokens": 60
  }
}

Code examples

cURL
Python
Node.js
Golang
curl -X POST https://DOMAIN/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "system", "content": "You are a professional coding assistant"},
      {"role": "user", "content": "Write a bubble sort in Python"}
    ],
    "temperature": 0.7,
    "max_tokens": 1024
  }'
# pip install openai
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://DOMAIN/v1"
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": "You are a professional coding assistant"},
        {"role": "user", "content": "Write a bubble sort in Python"},
    ],
    temperature=0.7,
    max_tokens=1024
)

print(response.choices[0].message.content)
print(f"Token usage: {response.usage.total_tokens}")
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://DOMAIN/v1",
});

async function main() {
  const res = await client.chat.completions.create({
    model: "gpt-4o-mini",
    messages: [
      { role: "system", content: "You are a professional coding assistant" },
      { role: "user", content: "Write a bubble sort in Python" },
    ],
    temperature: 0.7,
    max_tokens: 1024,
  });
  console.log(res.choices[0].message.content);
  console.log(`Token usage: ${res.usage.total_tokens}`);
}

main();
// go get github.com/sashabaranov/go-openai
package main

import (
    "context"
    "fmt"
    openai "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("YOUR_API_KEY")
    config.BaseURL = "https://DOMAIN/v1"
    client := openai.NewClientWithConfig(config)

    resp, err := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "gpt-4o-mini",
            Messages: []openai.ChatCompletionMessage{
                {Role: openai.ChatMessageRoleSystem, Content: "You are a professional coding assistant"},
                {Role: openai.ChatMessageRoleUser,   Content: "Write a bubble sort in Python"},
            },
        },
    )
    if err != nil {
        panic(err)
    }
    fmt.Println(resp.Choices[0].Message.Content)
}
API reference

Image understanding · Vision

Pass images in content as URLs or Base64 to enable image understanding. Vision models include gpt-4o、claude-3-5-sonnet、gemini-2.0-flash、qwen-vl-max and others.

Endpoint

POST /v1/chat/completions Image understanding (same Chat endpoint)
Image understanding uses the same /v1/chat/completions endpoint; the difference is that messages[].content contains an array with text and image content.

content structure (multimodal)

FieldTypeDescription
typestringtext(text) or image_url(image)
textstringText content when type is text
image_url.urlstringImage URL or Base64 Data URI (data:image/jpeg;base64,...)
image_url.detailstringauto/low/high; controls recognition detail, default: auto

Request example

cURL
Python
Node.js
curl https://DOMAIN/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{
      "role": "user",
      "content": [
        { "type": "text", "text": "What is in this image?" },
        { "type": "image_url", "image_url": { "url": "https://example.com/image.jpg" } }
      ]
    }]
  }'
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://DOMAIN/v1")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What is in this image?"},
            {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
        ]
    }]
)
print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://DOMAIN/v1" });

const res = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "What is in this image?" },
      { type: "image_url", image_url: { url: "https://example.com/image.jpg" } }
    ]
  }]
});
console.log(res.choices[0].message.content);
API reference

Streaming · Stream

Set stream: true to receive Tokens via Server-Sent Events (SSE), suitable for real-time conversations.

Endpoint

POST /v1/chat/completions stream: true

SSE response format

SSE Streamed chunks
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"delta":{"content":"!"}}]}

data: [DONE]
⚠️ The stream ends with data: [DONE]. Disconnect after receiving it.

Example code

Python
Node.js
cURL
from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://DOMAIN/v1")

stream = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Explain deep learning in one sentence"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
import OpenAI from "openai";

const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://DOMAIN/v1" });

const stream = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Explain deep learning in one sentence" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
console.log();
curl https://DOMAIN/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  --no-buffer \
  -d '{
    "model": "gpt-4o-mini",
    "stream": true,
    "messages": [{"role":"user","content":"Explain deep learning in one sentence"}]
  }'
Code examples

Complete chat example

Runnable chat examples for each language. Replace YOUR_API_KEY and DOMAIN to run.

HTTP / cURL

curl -X POST https://DOMAIN/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "deepseek-chat",
    "messages": [
      {"role": "system", "content": "You are a professional coding assistant"},
      {"role": "user", "content": "Write a bubble sort in Python"}
    ],
    "temperature": 0.7,
    "max_tokens": 1024
  }'

Python(openai SDK)

# pip install openai
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://DOMAIN/v1"
)

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[
        {"role": "system", "content": "You are a professional coding assistant"},
        {"role": "user", "content": "Write a bubble sort in Python"},
    ],
    temperature=0.7,
    max_tokens=1024
)

print(response.choices[0].message.content)
print(f"Token usage: {response.usage.total_tokens}")

Node.js(openai SDK)

// npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://DOMAIN/v1",
});

async function main() {
  const res = await client.chat.completions.create({
    model: "deepseek-chat",
    messages: [
      { role: "system", content: "You are a professional coding assistant" },
      { role: "user", content: "Write a bubble sort in Python" },
    ],
    temperature: 0.7,
    max_tokens: 1024,
  });
  console.log(res.choices[0].message.content);
  console.log(`Token usage: ${res.usage.total_tokens}`);
}

main();

Golang

// go get github.com/sashabaranov/go-openai
package main

import (
    "context"
    "fmt"
    openai "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("YOUR_API_KEY")
    config.BaseURL = "https://DOMAIN/v1"
    client := openai.NewClientWithConfig(config)

    resp, err := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "deepseek-chat",
            Messages: []openai.ChatCompletionMessage{
                {Role: openai.ChatMessageRoleSystem, Content: "You are a professional coding assistant"},
                {Role: openai.ChatMessageRoleUser,   Content: "Write a bubble sort in Python"},
            },
        },
    )
    if err != nil {
        panic(err)
    }
    fmt.Println(resp.Choices[0].Message.Content)
}
Code examples

Complete Vision example

These examples pass images as URLs or Base64 for image understanding.

Python — Image URL

from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://DOMAIN/v1")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this image"},
            {
                "type": "image_url",
                "image_url": {
                    "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
                    "detail": "high"
                }
            }
        ]
    }]
)
print(response.choices[0].message.content)

Python — Local Base64 image

import base64
from openai import OpenAI

def encode_image(image_path):
    with open(image_path, "rb") as f:
        return base64.b64encode(f.read()).decode("utf-8")

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://DOMAIN/v1")
b64 = encode_image("./image.jpg")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "How many people are in this image?"},
            {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{b64}"}}
        ]
    }]
)
print(response.choices[0].message.content)

Node.js

import fs from "fs";
import OpenAI from "openai";

const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://DOMAIN/v1" });
const b64 = fs.readFileSync("./image.jpg").toString("base64");

const res = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "How many people are in this image?" },
      { type: "image_url", image_url: { url: `data:image/jpeg;base64,${b64}` } }
    ]
  }]
});
console.log(res.choices[0].message.content);

Golang

package main

import (
    "context"; "encoding/base64"; "fmt"; "os"
    openai "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("YOUR_API_KEY")
    config.BaseURL = "https://DOMAIN/v1"
    client := openai.NewClientWithConfig(config)

    data, _ := os.ReadFile("./image.jpg")
    b64 := base64.StdEncoding.EncodeToString(data)
    dataURL := "data:image/jpeg;base64," + b64

    resp, _ := client.CreateChatCompletion(context.Background(),
        openai.ChatCompletionRequest{
            Model: "gpt-4o",
            Messages: []openai.ChatCompletionMessage{{
                Role: openai.ChatMessageRoleUser,
                MultiContent: []openai.ChatMessagePart{
                    {Type: openai.ChatMessagePartTypeText,     Text: "How many people are in this image?"},
                    {Type: openai.ChatMessagePartTypeImageURL, ImageURL: &openai.ChatMessageImageURL{URL: dataURL}},
                },
            }},
        })
    fmt.Println(resp.Choices[0].Message.Content)
}
Code examples

Complete streaming example

Streaming enables a “typewriter” effect for a better user experience.

Python

from openai import OpenAI

client = OpenAI(api_key="YOUR_API_KEY", base_url="https://DOMAIN/v1")

with client.chat.completions.stream(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Write a classical Chinese seven-character poem about spring"}]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Node.js

import OpenAI from "openai";

const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://DOMAIN/v1" });

const stream = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Write a classical Chinese seven-character poem about spring" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
console.log();

Golang (native HTTP)

package main

import (
    "bufio"; "bytes"; "encoding/json"; "fmt"
    "net/http"; "strings"
)

func main() {
    body, _ := json.Marshal(map[string]any{
        "model":  "gpt-4o-mini",
        "stream": true,
        "messages": []map[string]string{{"role": "user", "content": "Write a classical Chinese seven-character poem"}},
    })

    req, _ := http.NewRequest("POST", "https://DOMAIN/v1/chat/completions", bytes.NewBuffer(body))
    req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()

    scanner := bufio.NewScanner(resp.Body)
    for scanner.Scan() {
        line := scanner.Text()
        if !strings.HasPrefix(line, "data: ") { continue }
        data := strings.TrimPrefix(line, "data: ")
        if data == "[DONE]" { break }
        var chunk map[string]any
        json.Unmarshal([]byte(data), &chunk)
        choices := chunk["choices"].([]any)
        delta := choices[0].(map[string]any)["delta"].(map[string]any)
        if content, ok := delta["content"]; ok {
            fmt.Print(content)
        }
    }
}