Documentation
Everything you need to integrate the MAX API API.
Quick start
The MAX API API is compatible with the OpenAI API. If you already use an OpenAI SDK, change two settings: the base URL and the API key.
Authentication
Authenticate every request with your API key in the Authorization header. Keep your key secret — never expose it in browsers or mobile apps.
Authorization: Bearer YOUR_API_KEYChat completions
Send a list of messages and receive the model's reply. Any chat model ID from the catalog works.
curl https://clubs.byte-ai.cn/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-terra",
"messages": [{"role": "user", "content": "Hello!"}]
}'Streaming
Set stream to true to receive tokens as server-sent events (SSE) while they are generated. The stream ends with data: [DONE].
curl https://clubs.byte-ai.cn/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-terra",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'Image generation
Generate images with the Images API. Pick an image model from the catalog.
curl https://clubs.byte-ai.cn/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A lighthouse on a cliff at sunset, watercolor",
"size": "1024x1024"
}'Anthropic format
Claude models can also be called with the native Anthropic Messages format at /v1/messages, using the x-api-key header (the Authorization header also works). This lets you use the official Anthropic SDK unchanged.
curl https://clubs.byte-ai.cn/v1/messages \
-H "x-api-key: $API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'List models
Retrieve the models available to your key.
curl https://clubs.byte-ai.cn/v1/models \
-H "Authorization: Bearer $API_KEY"Error codes
Errors use standard HTTP status codes and an OpenAI-style JSON body:
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}| Status | Meaning |
|---|---|
| 400 | Bad request — invalid parameters or malformed JSON. |
| 401 | Invalid or missing API key. |
| 403 | Insufficient balance, or the key is not allowed to use this model. |
| 404 | Unknown endpoint or model not available. |
| 429 | Too many requests — slow down and retry with backoff. |
| 500 | Internal error — safe to retry. |
| 502 / 503 | Upstream temporarily unavailable — retry after a short delay. |
Rate limits
Default limits are generous and suitable for production workloads. If you exceed them you will receive 429 responses; retry with exponential backoff. Need higher throughput? Contact us through the console.
Long generations with reasoning models can take minutes. Set your client timeout to at least 300 seconds, or use streaming.
FAQ
Which SDKs are supported?+
Any OpenAI-compatible SDK or HTTP client: the official OpenAI SDKs for Python and Node.js, LangChain, LlamaIndex, and more. For Claude models the Anthropic SDK also works.
Do you support function calling and JSON output?+
Yes, for models that support them. Parameters such as tools, tool_choice and response_format are passed through to the model.
Can one key call every model?+
Yes. A single API key works across all models in the catalog; usage is billed per model at its list price.
How do I switch models?+
Change the model field in your request. No other changes are needed.