Quickstart
XycAi is a unified AI API gateway that exposes dozens of upstream model providers through a single OpenAI-compatible interface. If you have used the OpenAI SDK before, you barely need to change any code — just swap the base_url and api_key.
Prerequisites
- Sign up and log in to the console.
- Create a key on the API Keys page; it looks like
sk-xxxxxxxx. - Make sure your account has available balance.
Base URL
All requests go to the same gateway domain. Depending on the SDK or how you call it, the base_url takes one of three forms:
| Use case | URL |
|---|---|
| Domain only (build the path yourself) | https://apicdn.xyc.ai |
base_url for the OpenAI SDK | https://apicdn.xyc.ai/v1 |
| Full chat completions URL | https://apicdn.xyc.ai/v1/chat/completions |
The official OpenAI SDK automatically appends paths like /chat/completions to base_url, so set it to /v1 — do not put the full path there.
Authentication
Pass your key in the request header:
Authorization: Bearer sk-xxxxxxxx
A few native protocols use different headers: the Claude-native /v1/messages uses x-api-key, and the Gemini-native /v1beta uses x-goog-api-key. See Authentication.
Your First Request
The example below sends a chat completion with claude-sonnet-4-6.
from openai import OpenAI
client = OpenAI(
base_url="https://apicdn.xyc.ai/v1",
api_key="sk-xxxxxxxx",
)
resp = client.chat.completions.create(
model="claude-sonnet-4-6",
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://apicdn.xyc.ai/v1",
apiKey: "sk-xxxxxxxx",
});
const resp = await client.chat.completions.create({
model: "claude-sonnet-4-6",
messages: [
{ role: "user", content: "Introduce yourself in one sentence." },
],
});
console.log(resp.choices[0].message.content);
curl https://apicdn.xyc.ai/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [
{"role": "user", "content": "Introduce yourself in one sentence."}
]
}'
Response Structure
Returns a standard OpenAI-compatible structure:
{
"id": "chatcmpl-xxxxxxxx",
"object": "chat.completion",
"created": 1748600000,
"model": "claude-sonnet-4-6",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I am an AI assistant ..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 18,
"total_tokens": 30
}
}
Streaming
Add "stream": true to receive the response chunk by chunk (Server-Sent Events).
stream = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Write a four-line poem."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)
curl https://apicdn.xyc.ai/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [{"role": "user", "content": "Write a four-line poem."}],
"stream": true
}'
Popular Models
The same endpoint can switch between models from different providers — just change the model field. A few popular ones:
| Model | Type | Notes |
|---|---|---|
claude-opus-4-8 | Chat | Anthropic flagship, complex reasoning and long context |
claude-sonnet-4-6 | Chat | Balanced speed and quality, everyday default |
gpt-5.4 | Chat | OpenAI general-purpose chat model |
gpt-5.3-codex | Chat / Code | Code-focused model |
gemini-3-pro-preview | Chat | Google multimodal model |
deepseek-v4-pro | Chat | High-performance DeepSeek model |
nano-banana-pro | Image | Image generation |
sora-2 | Video | Video generation |
See the full list at Models.
Common Errors
On failure the response has the structure below, with a request id appended to message to aid debugging:
{
"error": {
"code": "",
"message": "Invalid token (request id: 2026053012xxxx)",
"type": "new_api_error"
}
}
Common HTTP status codes: 401 unauthenticated, 403 forbidden, 429 rate limited / insufficient balance, 400 bad request, 500/503 upstream error. See Errors.