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

ParameterTypeDescription
modelrequiredstringThe virtual model ID to use. Call GET /v1/models to list the model IDs available on your account.
messagesrequiredarrayArray of message objects. Each has role ("system", "user", or "assistant") and content (string).
streambooleanIf true, tokens are sent as server-sent events as they are generated. Defaults to false.
temperaturenumberSampling temperature between 0 and 2. Higher values produce more random output. Defaults to 1.
max_tokensintegerMaximum tokens to generate. Defaults to model maximum if not set.
top_pnumberNucleus sampling — only the top-p probability mass is considered. Defaults to 1.
stopstring | arrayUp to 4 sequences where the API will stop generating. Can be a string or array of strings.
nintegerNumber of chat completion choices to generate. Defaults to 1.

Example request

request.json
{
  "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

response.json
{
  "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].

stream response
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

Errors return {"error": {"message", "type", "code", "param"?, "request_id"?}} — see the Error Handling guide for the full envelope and which codes to retry.

400
invalid_message_role / missing_input / context_length_exceeded
Bad request body — unsupported role, missing messages, or input too long for the model.
401
invalid_api_key
Missing, invalid, or expired API key. Check the Authorization header.
402
insufficient_credit
Wallet balance is too low. Top up at Dashboard → Add credits.
403
kyc_required / insufficient_scope
KYC verification is required before this call, or the API key lacks the required scope.
404
model_not_found
The model ID in the request does not exist or is not available to your account.
429
rate_limit_exceeded
Too many requests, or a per-key RPM/TPD limit was hit. Slow down and retry with exponential backoff.
503
model_unavailable
Every configured route for this model failed or timed out. Retry after a short wait — this is not something to fix in your request.
Live Playground

Get your key from Dashboard → API Keys. Stored only in your browser.