XycAi speaks the OpenAI, Anthropic and Google Gemini wire formats. Point the official SDK at XycAi and call Claude / GPT / Gemini / GLM / DeepSeek / Kimi and 20+ other vendors without touching your business code.
https://cn.chatapi.app (primary; global / backup endpoints on the Endpoints page)sk-…) created under API Keys in the console, routed by vendor by default/v1/chat/completions), Anthropic native (/v1/messages), OpenAI Responses (/v1/responses, GPT models), Gemini native (/v1beta/models/{model}:generateContent), image generation (/v1/images/generations) and video generation (/v1/video/generations)Replace sk-xxxxxxxx with your own key. Never commit it to a repository or ship it in client-side code; if it leaks, delete and recreate it in the console.
Pick the endpoint and the protocol you use; the widget shows the exact base URL to copy:
Each protocol authenticates with its own header:
| Protocol | Header | Path |
|---|---|---|
| OpenAI-compatible | Authorization: Bearer sk-xxxxxxxx | /v1/chat/completions and other /v1/* |
| Anthropic native | x-api-key: sk-xxxxxxxx + anthropic-version: 2023-06-01 | /v1/messages |
| OpenAI Responses | Authorization: Bearer sk-xxxxxxxx | /v1/responses |
| Gemini native | x-goog-api-key: sk-xxxxxxxx (or ?key=) | /v1beta/models/{model}:generateContent |
The OpenAI SDK appends /chat/completions etc. itself, so set base_url to https://cn.chatapi.app/v1 — not the full path. The Anthropic SDK's ANTHROPIC_BASE_URL takes the bare host https://cn.chatapi.app.
Create an account at www.xycai.us.
On the API Keys page create a key. By default it routes by vendor: pick Anthropic and the key can reach every Claude model, with the gateway choosing the cheapest available pricing group for each request. You can also restrict it by model or open it to all models and vendors. See API keys & routing.
Requests are billed against your balance; every call appears in the usage log.
The example sends a Chat Completions request to claude-sonnet-5-5 over the OpenAI-compatible protocol (which works for every vendor).
from openai import OpenAI
client = OpenAI(
base_url="https://cn.chatapi.app/v1",
api_key="sk-xxxxxxxx",
)
resp = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[{"role": "user", "content": "Introduce yourself in one sentence."}],
)
print(resp.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://cn.chatapi.app/v1",
apiKey: "sk-xxxxxxxx",
});
const resp = await client.chat.completions.create({
model: "claude-sonnet-5-5",
messages: [{ role: "user", content: "Introduce yourself in one sentence." }],
});
console.log(resp.choices[0].message.content);
curl https://cn.chatapi.app/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"messages": [{"role": "user", "content": "Introduce yourself in one sentence."}]
}'
With the Anthropic SDK or Claude Code, just point the base URL at XycAi:
from anthropic import Anthropic
client = Anthropic(base_url="https://cn.chatapi.app", api_key="sk-xxxxxxxx")
msg = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(msg.content[0].text)
curl https://cn.chatapi.app/v1/messages \
-H "x-api-key: sk-xxxxxxxx" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, Claude"}]
}'
Add "stream": true to receive the response as Server-Sent Events. Use streaming for anything long-running (agents, long generations) so idle timeouts on intermediate network gear never cut the request.
stream = client.chat.completions.create(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Write a four-line poem."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
curl https://cn.chatapi.app/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-5.6-terra", "messages": [{"role": "user", "content": "Write a four-line poem."}], "stream": true}'
Switch vendors by changing the model field. Frequently used names (full catalogue on the Models page):
| Model | Vendor | Type | Notes |
|---|---|---|---|
claude-fable-5 | Anthropic | Chat | Anthropic's strongest flagship for complex reasoning and long tasks |
claude-opus-5-5 / claude-sonnet-5-5 / claude-haiku-5-5 | Anthropic | Chat | Claude 5.5 tiers, the Claude Code default |
gpt-6.1-sol / gpt-6.1-terra / gpt-6-astra | OpenAI | Chat | GPT-6 flagship and balanced tiers, Codex-ready |
gemini-4-argon | Chat | Gemini 4, multimodal with very long context | |
glm-5.3 / glm-5.3-flash | Zhipu | Chat | Chinese flagship, no queueing |
kimi-k3 / deepseek-v4-pro / qwen3.8-max | Kimi / DeepSeek / Qwen | Chat | Cost-effective Chinese flagships |
gpt-image-2.5-flare | OpenAI | Image | GPT image generation, billed per image |
nano-banana-pro | Image | Nano Banana image generation (Economy, per image) | |
grok-imagine-video | xAI | Video | Text-to-video / image-to-video |
Failures return the structure below; the message ends with a request id — include it when contacting support:
{
"error": {
"code": "",
"message": "Invalid token (request id: 2026102212xxxx)",
"type": "new_api_error"
}
}
Common status codes: 401 invalid key, 403 the key's routing mode does not include that model / vendor, 429 concurrency limit or insufficient balance, 400 bad request, 5xx upstream failure after automatic retries. See Errors.