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:
Authorization: Bearer $AIROUTER_API_KEY
Content-Type: application/json
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 | Default model for this request. AI Router still chooses among the candidate models; a concrete name here does not pin the request. auto uses the team default. See Default Model. |
models | array of strings | team's enabled models | Candidate allowlist for this request. A model with reasoning efforts stands for all its efforts, <model>_<effort> for that effort only. A single model turns the request into a plain gateway call to that model; this is how you pin a model. 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 caps the predicted completion length used for the cost and latency prediction. |
tools | array | - | Standard OpenAI tool definitions. When present, only models with tool support are considered. |
reasoning_effort | string | - | When AI Router selects a reasoning effort, it replaces this value. Otherwise, for example in a gateway call, it is passed through and clamped to the efforts the model supports. |
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.
The x-airouter-routing-outcome response header describes whether AI Router made a routing decision. routed covers both the ranked winner and any in-decision fallback to the next-best ranked candidate described above. default means AI Router made no decision and the request ran on the default model.
If the header is absent or contains an unrecognized value, treat the outcome as unknown, never as default. Clients should expect the value set to grow.
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> |
<selected_model> is the model name only. AI Router also selects a reasoning effort, but this format cannot carry it; the Decision API returns it in effort. To fix the effort on this path, list only one effort per model in models (for example gpt-6-luna_low).
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). |
404 | A name in model or models is not a supported model. |
503 | No usable provider key is available for the selected models, or none of your connected models can be selected for the request. Connect a provider key. |
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-6-luna", "gemini-3.8-flash", "claude-haiku-5-5"],
"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
}