Your first API call
Break down a chat completion to understand request fields, response shape and common mistakes. No live call is made.
On this page
The minimal request
A working request needs only two fields: model and messages.
{
"model": "claude-sonnet-4-6",
"messages": [
{ "role": "system", "content": "You are a concise technical assistant." },
{ "role": "user", "content": "What is the APIONE base_url?" }
]
}The three message roles
systemstringSets behaviour and tone; put it first. Some vendors expect a separate field — the gateway converts it for you.
userstring | arrayUser input. Multimodal models accept an array mixing text and images.
assistantstringThe model's previous reply. Send history back verbatim — the server keeps no session.
The API is stateless. Multi-turn conversations require you to resend the full messages array each time; longer context means more input tokens and higher cost.
Common optional parameters
| Parameter | Type | Default | Notes |
|---|---|---|---|
temperature | number | 1 | 0–2; lower is more deterministic. Use 0 for extraction. |
max_tokens | integer | model max | Caps this reply — a safety net against runaway output. |
stream | boolean | false | Switches to SSE streaming; see Streaming. |
tools | array | — | Function-calling definitions, OpenAI format. |
response_format | object | — | Constrain output to JSON or a schema. |
Response shape
{
"id": "chatcmpl-01J8ZQ7K3M",
"object": "chat.completion",
"created": 1771286400,
"model": "claude-sonnet-4-6",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "https://api.apione.ai/v1" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 42, "completion_tokens": 12, "total_tokens": 54 }
}id— identifies this completion. For support, theX-Maxx-Request-IDresponse header is more useful: search it in console › Usage › Request log to find the call.finish_reason—stopcompleted,lengthhitmax_tokens,tool_callsneeds you to run a tool and send results back.usage— the billing basis; cached input appears underprompt_tokens_details.
Four common mistakes
| Symptom | Cause | Fix |
|---|---|---|
401 invalid API token | Whitespace or newline copied with the key | Re-copy, or inject via environment variable |
404 not_found | base_url missing /v1 | Use https://api.apione.ai/v1 |
400 model_not_supported | Model ID misspelled or copied from elsewhere | Check the IDs from GET /v1/models |
| Truncated reply | max_tokens too small | Raise it, and check finish_reason |
Next
- Reference › POST /chat/completions — the full parameter table.
- Error codes — status codes and retry strategy.
Contact us
Something unclear, or need a human? Pick the channel that fits your question.
Supportsupport@apione.ai
WeCom
Telegram
Communityhttps://t.me/apione
Support tickets
Billing & accountConsole › Feedback