API Reference
POST/v1/chat/completions
Chat Completions
Creates a model response for the given conversation. Fully compatible with the OpenAI Chat Completions API — existing SDKs work without modification.
Request body
| Parameter | Type | Description |
|---|
modelrequired | string | The virtual model ID to use. Call GET /v1/models to list the model IDs available on your account. |
messagesrequired | array | Array of message objects. Each has role ("system", "user", or "assistant") and content (string). |
stream | boolean | If true, tokens are sent as server-sent events as they are generated. Defaults to false. |
temperature | number | Sampling temperature between 0 and 2. Higher values produce more random output. Defaults to 1. |
max_tokens | integer | Maximum tokens to generate. Defaults to model maximum if not set. |
top_p | number | Nucleus sampling — only the top-p probability mass is considered. Defaults to 1. |
stop | string | array | Up to 4 sequences where the API will stop generating. Can be a string or array of strings. |
n | integer | Number of chat completion choices to generate. Defaults to 1. |
Example request
{
"model": "default",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"temperature": 0.7,
"max_tokens": 256,
"stream": false
}
Response
Returns a chat.completion object when stream=false, or a stream of chat.completion.chunk events when stream=true.
Non-streaming response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1748000000,
"model": "default",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 9,
"total_tokens": 37
}
}
Streaming response (SSE)
Each line is a data: event. Read choices[0].delta.content and concatenate chunks until you receive data: [DONE].
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"delta":{"role":"assistant"},"index":0}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"delta":{"content":"The"},"index":0}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"delta":{"content":" capital"},"index":0}]}
data: [DONE]
Error codes
401Unauthorized
Missing or invalid API key. Check the Authorization header.
402Insufficient balance
Wallet balance is too low. Top up at Dashboard → Add credits.
422Validation error
Request body is malformed. Check the required fields above.
429Rate limited
Too many requests. Slow down and retry with exponential backoff.
502Upstream error
All available routes for this model failed. Retry the request after a short wait.