TheaimartAIx DOCS
Home Get API key

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

FieldTypeNotes
modelstringRequired. Canonical model id.
messagesarrayRequired. {role, content}; roles: system / user / assistant.
streamboolSSE token streaming — see Streaming.
temperaturenumber0–2. Default 0.7.
max_tokensintMax output tokens. Default 256.
top_pnumberNucleus sampling. Default 1.0.
stopstring | arrayStop sequence(s).
presence_penaltynumber−2 to 2.
frequency_penaltynumber−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.

Last updated July 18, 2026

Was this page helpful?