Chat completions
POST /v1/chat/completions
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | required | Canonical model id, e.g. anthropic/claude-sonnet-4-6. |
messages | array | required | OpenAI messages. content is a string or a multimodal array (vision). Roles: system, user, assistant, tool. |
stream | boolean | default: false | Stream SSE chat.completion.chunk events. |
temperature | number | default: 0.7 | Sampling temperature, 0–2. |
max_tokens | integer | default: 256 | Max output tokens. |
top_p | number | default: 1.0 | Nucleus sampling. |
stop | string | array | optional | Stop sequence(s). |
n | integer | default: 1 | Number of choices. |
presence_penalty | number | default: 0 | −2 to 2. |
frequency_penalty | number | default: 0 | −2 to 2. |
tools | array | optional | Function/tool definitions. See tool calling. AIx selects a compatible execution path. |
tool_choice | string | object | optional | auto · none · required · a specific function. |
response_format | object | optional | {"type":"json_object"} or json_schema. See structured outputs. |
Example
curl https://api.aix.theaimart.co/v1/chat/completions \
-H "Authorization: Bearer $AIX_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "deepseek-ai/DeepSeek-V3.2",
"messages": [{"role":"user","content":"hi"}] }' client.chat.completions.create(
model="deepseek-ai/DeepSeek-V3.2",
messages=[{"role": "user", "content": "hi"}],
) await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V3.2",
messages: [{ role: "user", content: "hi" }],
}); Try it
Try it Runs a live request with your key — stored only in this browser.
Response — chat.completion
{
"id": "chatcmpl-…",
"object": "chat.completion",
"created": 1718900000,
"model": "deepseek-ai/DeepSeek-V3.2",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "…", "tool_calls": [] },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 }
}
The response preserves the standard chat.completion shape, including tool_calls,
logprobs and structured-output results when supported by the selected model.
Streaming
With stream: true the response is text/event-stream of chat.completion.chunk events,
terminated by data: [DONE]. See Streaming.
Errors
400 unsupported model / bad params · 401/403 auth · 402 insufficient credits ·
429 rate limit · 503 no healthy route available. See Errors.