API reference › Resources
Chat
Call an AI model directly, without an agent, with a full response or streaming.
POST/api/chat/completions#
Sends messages straight to a model, with no agent instructions, connectors or saved history. Use it to classify, summarize, extract data or generate text inside your systems.
| Field | Type | Description |
|---|---|---|
messages | array, 1 to 200 | Required. Items { "role": "user" | "assistant", "content": "text" }. |
model | string | provider/model, for example anthropic/claude-sonnet-5.5. Without it, the default is used: DoubleX Auto (openrouter/auto) in organizations with platform credits. See the IDs in Models. |
system | string | System instruction. |
maxTokens | number, 1 to 128,000 | Token limit for the response. |
temperature | number, 0 to 2 | |
stream | boolean | true to receive it in chunks. Default false. |
Full response#
curl -X POST https://doublex.ai/api/chat/completions \
-H "Authorization: Bearer $DOUBLEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"system": "Reply with only Positive, Negative or Neutral.",
"messages": [{ "role": "user", "content": "Loved the service, they solved it fast." }]
}'JSON
{
"provider": "openrouter",
"model": "openrouter/auto",
"servedModel": "google/gemini-3.8-flash",
"text": "Positive",
"usage": { "inputTokens": 31, "outputTokens": 2, "costUsd": 0.00002 }
}servedModel is the model that actually answered (useful with DoubleX Auto).
Streaming#
With "stream": true, the response arrives as NDJSON:
NDJSON
{"type":"delta","text":"Posi"}
{"type":"delta","text":"tive"}
{"type":"done","provider":"openrouter","model":"openrouter/auto","servedModel":"google/gemini-3.8-flash","text":"Positive","usage":{"inputTokens":31,"outputTokens":2,"costUsd":0.00002}}type | Fields |
|---|---|
delta | text: the next chunk of the response. |
done | The full response, with text, usage and the model used. |
error | error: the error message. |
If you close the connection midway, the model call is cancelled too.
Errors#
| Status | code | When |
|---|---|---|
400 | no_provider | No model is available to you. |
400 | model_unavailable | The requested model isn't in the catalog or isn't enabled. |
402 | no_credits | The organization is out of credits. |
402 | plan_required | The organization has not chosen a plan yet. |
502 | provider_error | The model provider failed. In streaming, it arrives as an error event. |
Each call consumes credits based on the model's cost and shows up in the Usage and credits report with the source Terminal (CLI).