POST https://api.airouter.io/v1/chat/completions is a drop-in replacement for the OpenAI chat completions endpoint (/chat/completions without the /v1 prefix works as well). Send your AI Router API key as a bearer token:
Everything the OpenAI API supports (streaming, tool calling, response formats, temperature, max_tokens, ...) is passed through to the selected model. On top of that, AI Router understands the following parameters. With the OpenAI SDKs, put them into extra_body; with LangChain, into model_kwargs.extra_body.
| Parameter | Type | Default | Description |
|---|---|---|---|
model | string | team default | A concrete model name pins the request to that model. auto (or omitting it while the team default is auto) lets AI Router decide. See Default Model. |
models | array of strings | team's enabled models | Candidate allowlist for this request. A single model turns the request into a plain gateway call. See Choosing Models. |
weighting | object | team preferences | quality, costs and latency boost factors, each a non-negative number. See Weighting. |
model_routing | boolean | true | false returns the selected model name instead of executing the request (model selection mode, see below). |
embedding | array of numbers | - | Full privacy mode: the embedding of the prompt instead of messages. Implies model_routing: false. |
embedding_type | string | paraphrase-multilingual-mpnet-base-v2 | Embedding model of embedding: text-embedding-3-small or the FastEmbed default. |
max_tokens | integer | - | Also used as the expected completion length for the cost and latency prediction. |
tools | array | - | Standard OpenAI tool definitions. When present, only models with tool support are considered. |
reasoning_effort | string | - | Passed through and clamped to the tiers the selected model supports. |
expose_predicted_savings | boolean | false | Model selection mode only: append the predicted cost and latency savings to the response. |
expose_decision_id | boolean | false | Model selection mode only: append the routing decision id for usage reporting. |
Per-request parameters override the team configuration for that request; API key overrides override the team configuration for every request of that key.
The response is a standard chat completion object. model in the response names the model that produced the answer. When the selected model fails, AI Router automatically falls back to the next best candidates of the same decision; with connected provider keys the fallback chain stays on your own keys.
model_routing: false)With model_routing: false AI Router returns the selected model name as the message content instead of calling the model:
The content of choices[0].message.content is comma-separated:
| Options | Content |
|---|---|
| none | <selected_model> |
expose_decision_id | <selected_model>,<decision_id> |
expose_predicted_savings | <selected_model>,<cost_savings>,<latency_savings> |
| both | <selected_model>,<cost_savings>,<latency_savings>,<decision_id> |
The savings are fractions relative to AI Router's reference model (0.41 means 41% lower predicted cost). This is the legacy selection path used by the Python and TypeScript SDKs; new integrations should prefer the Decision API, which returns a structured, ranked response.
| Status | Meaning |
|---|---|
400 | Invalid parameters, for example unknown weighting keys. |
401 | Missing or invalid API key. |
403 | The feature is not included in your plan (model routing, full privacy). |
503 | No usable provider key is available for the selected models. Connect a provider key. |
Authorization: Bearer $AIROUTER_API_KEY
Content-Type: application/json
curl https://api.airouter.io/v1/chat/completions \
--request POST \
--header "Authorization: Bearer $AIROUTER_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "auto",
"messages": [{"role": "user", "content": "Explain quantum tunnelling."}],
"models": ["gpt-5-mini", "gemini-3.5-flash", "claude-4-5-haiku"],
"weighting": {"quality": 1.0, "costs": 2.0, "latency": 1.0},
"stream": false
}'
{
"model": "auto",
"messages": [{"role": "user", "content": "Explain quantum tunnelling."}],
"model_routing": false,
"expose_decision_id": true
}