Skip to main content

Native API Calls (SDK Examples)

Replace {baseUrl} with your platform API root, without a trailing / or /v1, and sk-your-api-key with your model API key. Select models supported by your token's group.

Python (OpenAI SDK)​

pip install openai
from openai import OpenAI

client = OpenAI(
api_key="sk-your-api-key",
base_url="{baseUrl}/v1",
)

resp = client.chat.completions.create(
model="gpt-5.2",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain intelligent routing in one sentence."},
],
)
print(resp.choices[0].message.content)

Streaming​

stream = client.chat.completions.create(
model="gpt-5.2",
messages=[{"role": "user", "content": "Write a four-line poem about a tree."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)

Node.js (openai package)​

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
apiKey: "sk-your-api-key",
baseURL: "{baseUrl}/v1",
});

const resp = await client.chat.completions.create({
model: "gpt-5.2",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);

Anthropic SDK​

pip install anthropic
from anthropic import Anthropic

client = Anthropic(
api_key="sk-your-api-key",
base_url="{baseUrl}", # Do not append /v1
)

msg = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)

Google GenAI SDK (native Gemini)​

pip install google-genai
from google import genai

client = genai.Client(
api_key="sk-your-api-key",
http_options={"base_url": "{baseUrl}"},
)

resp = client.models.generate_content(
model="gemini-2.5-pro",
contents="Hello",
)
print(resp.text)

Image and video generation​

For the OpenAI-compatible image endpoint, create an OpenAI client:

from openai import OpenAI

client = OpenAI(api_key="sk-your-api-key", base_url="{baseUrl}/v1")
resp = client.images.generate(
model="gemini-3-pro-image",
prompt="A red fox standing in the snow, photorealistic",
size="1024x1024",
)
print(resp.data[0].url)

Video generation uses asynchronous tasks: submit a request, save the returned task_id, and poll for results. The platform provides shared video generation and task-query endpoints as well as provider-specific endpoints for Kling, Sora, Jimeng, and Volcengine. See the video generation API for parameters.

MiniMax H3/H3-Max, H3 2K upgrades, and Context-IR use native asynchronous /v2 endpoints. See the MiniMax H3 integration guide. The returned task_id is a platform task ID; read task.content.url for video or task.content.prompt for Context-IR.

Endpoint reference​

EndpointMethodPurpose
/v1/modelsGETList available models
/v1/chat/completionsPOSTChat completions
/v1/responsesPOSTResponses API
/v1/messagesPOSTNative Anthropic messages
/v1/embeddingsPOSTText embeddings
/v1/audio/speechPOSTText to speech
/v2/video_generationPOSTMiniMax H3/H3-Max video generation
/v2/video_regenerationPOSTH3 2K upgrade
/v2/h3_context_irPOSTContext-IR prompt generation
/v2/query/video_generation/{task_id}GETQuery MiniMax H3 tasks
/v1beta/modelsGETNative Gemini model list
/api/user/selfGETAccount information; requires a management access token
/api/log/selfGETRequest logs; requires a management access token