API
Chat Completions
POST /v1/chat/completions takes OpenAI's request body and returns OpenAI's response shape.
POST /v1/chat/completions takes the same body as OpenAI's Chat Completions API and returns the same shape.
Every text model on sale answers on this route.
POST/v1/chat/completions
Authorization
| Parameter | Details |
|---|---|
Authorizationstringheaderrequired | Your API key as See Authentication. |
Request body
| Parameter | Details |
|---|---|
modelstringrequired | A slug from the model list, for example |
messagesobject[]required | The conversation so far, as OpenAI Show child attributesHide child attributes
The message text.
On an
On a |
max_tokensinteger | Upper bound on output tokens, reasoning included. If it runs out while the model is still reasoning, the reply has |
temperaturenumber | Sampling temperature. |
toolsobject[] | Functions the model may call, in OpenAI's See Tool calls. Only A Server-side tools that cost extra, such as web search (a Show child attributesHide child attributes
The function's |
tool_choicestring or object |
Forcing a call with |
response_formatobject | Ask for JSON output, as in OpenAI's API: |
streamboolean | Send the reply as server-sent events. See Streaming. |
stream_optionsobject | With See Usage in the stream. |
Response
The same shape as OpenAI's.
The response can carry other fields that OpenAI's doesn't; ignore any you don't use.
| Parameter | Details |
|---|---|
objectstring |
|
modelstring | The model that answered. |
choicesobject[] | The reply. Show child attributesHide child attributes
The reply as Reasoning models also return the model's thinking in |
usageobject | Tokens counted for the bill: |
Audio input
Some models take speech: azrouter models --json lists audio in a model's input, for example google/ and google/.
Send the file in the user message as an input_audio part: data is the file in base64, format is wav. Ask for the transcript, a summary or anything else in a text part beside it.
An audio request holds some credit before the answer starts, then charges only what was used. Set max_tokens to the longest answer you need: it keeps the hold small.
The audio is billed as input tokens, at the model's price per million tokens.
Tool calls
Describe your functions in tools.
When the model wants one, the reply has finish_reason: "tool_calls" and the call in message.tool_calls.
Run the function yourself, then send its result back as a {"role": "tool", "tool_call_id": ..., "content": ...} message in the next request.