Create a chat completion
The OpenAI chat completions API, for every certified language model. Supports streaming, tools, and structured output. Dispatch picks the provider; the model you request is the model that answers, unless you allow model fallback. For Claude, POST /v1/messages speaks the Anthropic API natively.
Body
application/json, up to 1 MiB- modelstringrequired
Model slug, e.g.
openai/gpt-4o-mini. Slugs match OpenRouter. A vendor's own name (gpt-5-mini,claude-sonnet-4-5-20250929) resolves to the catalog id when exactly one model matches. A team alias such asorg/fastruns as the model it names, with its preset's defaults for fields you leave out.GET /v1/modelslists the ones your key may call. - messagesarrayrequired
The conversation so far. At least one message.
- streambooleanoptional
Return server-sent events as tokens are generated.
- max_tokensintegeroptional
Upper bound on generated tokens. Also sets how much balance is reserved.
max_completion_tokensis accepted too. When neither is sent, output is limited to 4,096 tokens (or yourmaxOutputTokensDirective), never more than the model's maximum. - toolsarrayoptional
Functions the model may call: tools of type
function(orcustom). Other tool types are refused withunsupported_parameter, as areweb_search_optionsand OpenRouter'splugins; see Web search. - tool_choicestring | objectoptional
Force, allow, or forbid tool calls.
- parallel_tool_callsbooleanoptional
Allow several tool calls in one turn.
- response_formatobjectoptional
Constrain output to JSON or a JSON schema.
- temperaturenumberoptional
Sampling temperature.
- top_pnumberoptional
Nucleus sampling.
- stopstring | arrayoptional
Sequences that end generation.
- seedintegeroptional
Best-effort deterministic sampling.
- reasoningobjectoptional
Reasoning controls for models that support them.
- stream_optionsobjectoptional
Pass
{ "include_usage": true }for a final usage chunk. - nintegeroptional
Only
1is supported. - userstringoptional
Your end user, up to 256 characters: recorded on the request for attribution and per-end-user Directives, never forwarded.
safety_identifieris read the same way whenuseris absent (and is forwarded, as sent). Theib-userheader wins over both. - metadata, store, models, providerOptionsoptional
Accepted and not forwarded. Providers are always chosen by Dispatch, never by the request.
- ibobjectoptional
Inference Bureau extension, removed before dispatch.
tags: up to ten tags for cost breakdowns. For mixed-model sessions:session,suggestion,decision,confirmed_by,task, ignored unless the key is opted in. In the OpenAI SDKs, pass it withextra_body(Python) or as an extra field (TypeScript).
Headers
- Authorizationstringrequired
Bearer ib_live_…, or the key inx-api-key. See Authentication. - Content-Typestringrequired
application/json. Anything else is refused with400 invalid_request. - Idempotency-Keystringoptional
Makes retries safe: a repeated key never starts a second generation. Kept for 24 hours. See Request IDs.
- X-Client-Request-IDstringoptional
Your own correlation id, recorded on the receipt.
- ib-sessionstringoptional
Groups this turn with the rest of its conversation, like
ib.session. See Sessions. - ib-userstringoptional
Your end user, up to 256 characters; wins over
user. See End users and tags. - ib-tagsstringoptional
Comma-separated tags, such as
search,onboarding, added toib.tags; at most ten in all. Never sent upstream.
Response headers
| Header | Meaning |
|---|---|
X-Request-ID | Look up the request in Logs or via GET /v1/requests/:id. |
Retry-After | On 429, seconds to wait before retrying. Also sent when a provider asked for a cooldown. |
X-RateLimit-Scope | On 429, which level's limit was hit: organization, project, environment, key, or end_user (a per-end-user limit). The management API sends management_key or management_writes (see Management), and reading logged content content_read. |
X-RateLimit-Dimension | On 429, which limit was hit: requests, tokens or concurrency, or an end user's daily_requests or daily_tokens. These are your Directives rate limits, which every team has by default. |
X-Original-Request-ID | On a 409 for a repeated Idempotency-Key, the request that first used it. |
ib-fallback-model | A fallback model answered instead of the requested one; names it. |
ib-alias-deprecated | The request named a deprecated alias: its retirement date, and replaced-by= its replacement when it has one. |
ib-suggestion, ib-session, … | Keys opted in to mixed-model sessions. |
Limits
Request bodies are limited to 1 MiB (413 payload_too_large). A request has 240 seconds overall. A stream must start within 30 seconds, and is ended if it then sends nothing for 30 seconds. A non-streamed response may take the whole 240 seconds; past that the request fails with 504 request_deadline_exceeded. A stream that breaks after it started sends a final data: {"error": { "code": "stream_interrupted", … } } event and closes without [DONE]; see Errors.
Input plus max_tokens must fit the model's context window, or the request is refused with 400 context_limit_exceeded before anything is reserved.