Chat Completions
The most common endpoint, fully compatible with OpenAI Chat Completions. Works for all chat models — Claude, GPT, Gemini, DeepSeek — just change the model.
POST
https://apicdn.xyc.ai/v1/chat/completions
Request Parameters
| Parameter | Type | Notes |
|---|---|---|
model | string | Required. Model name, see Models |
messages | array | Required. Array of messages, each with role and content |
stream | bool | Whether to stream the response, default false |
temperature | number | Sampling temperature |
max_tokens | int | Maximum tokens to generate |
top_p | number | Nucleus sampling |
tools | array | Tool / function-calling definitions |
response_format | object | Structured output, e.g. {"type":"json_object"} |
Basic Request
from openai import OpenAI
client = OpenAI(base_url="https://apicdn.xyc.ai/v1", api_key="sk-xxxxxxxx")
resp = client.chat.completions.create(
model="claude-opus-4-8",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain what a vector database is."},
],
temperature=0.7,
)
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: "gpt-5.4",
messages: [
{ role: "system", content: "You are a concise assistant." },
{ role: "user", content: "Explain what a vector database is." },
],
});
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": "deepseek-v4-pro",
"messages": [
{"role": "user", "content": "Explain what a vector database is."}
]
}'
Streaming
Set stream: true to receive chat.completion.chunk events via SSE, ending with data: [DONE].
stream = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Stream the text: hello"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Multimodal (Image Input)
For vision-capable models, content can be an array mixing text and images:
{
"model": "gemini-3-pro-preview",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/a.jpg"}}
]
}
]
}
Tool Calling
Declare callable functions via tools; the model returns tool_calls when needed:
{
"model": "gpt-5.4",
"messages": [{"role": "user", "content": "What is the weather in Beijing?"}],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Look up the weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}
]
}
Response Structure
{
"id": "chatcmpl-xxxxxxxx",
"object": "chat.completion",
"model": "claude-opus-4-8",
"choices": [
{"index": 0, "message": {"role": "assistant", "content": "..."}, "finish_reason": "stop"}
],
"usage": {"prompt_tokens": 20, "completion_tokens": 120, "total_tokens": 140}
}