Chat completions
POST /v1/chat/completions — the OpenAI chat schema across the AIx chat catalog, with
health-aware route selection and automatic failover.
Request
curl https://api.aix.theaimart.co/v1/chat/completions \
-H "Authorization: Bearer $AIX_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"messages": [
{ "role": "system", "content": "You are a senior Rust engineer." },
{ "role": "user", "content": "Make this function async." }
],
"temperature": 0.4,
"max_tokens": 1024
}' r = client.chat.completions.create(
model="anthropic/claude-sonnet-4-6",
messages=[{"role": "user", "content": "Make this function async."}],
temperature=0.4,
)
print(r.choices[0].message.content) const r = await client.chat.completions.create({
model: "anthropic/claude-sonnet-4-6",
messages: [{ role: "user", content: "Make this function async." }],
temperature: 0.4,
});
console.log(r.choices[0].message.content); Try it
Try it Runs a live request with your key — stored only in this browser.
Parameters
| Field | Type | Notes |
|---|---|---|
model | string | Required. Canonical model id. |
messages | array | Required. {role, content}; roles: system / user / assistant. |
stream | bool | SSE token streaming — see Streaming. |
temperature | number | 0–2. Default 0.7. |
max_tokens | int | Max output tokens. Default 256. |
top_p | number | Nucleus sampling. Default 1.0. |
stop | string | array | Stop sequence(s). |
presence_penalty | number | −2 to 2. |
frequency_penalty | number | −2 to 2. |
Response
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "anthropic/claude-sonnet-4-6",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "…" },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 41, "completion_tokens": 128, "total_tokens": 169 }
}
The response matches the OpenAI chat.completion shape. Tool calls and structured-output
fields are preserved when supported by the chosen model.
Billing
We deduct an estimate up front, then reconcile down to the reported token usage. See Billing.
Prompts are data, not code to sanitize. Backticks,
$, angle brackets and full code blocks pass through untouched — built for coding workloads.