Create a chat completion (OpenAI-compatible)
https://api.stav.ai/v1/chat/completionsGenerates a model response for a conversation. Drop-in for the
OpenAI Python or TypeScript SDK — set base_url="https://api.stav.ai/v1"
and your existing code works.
Supports streaming via SSE (stream=true), function calling
(tools[]), structured output (response_format), extended
thinking (reasoning_effort), and prompt caching markers
(cache_control on messages, tools and the system prompt, where
the underlying model supports it).
Pass model="auto" to invoke the Smart Router, or
@workspace-slug/router-slug to use one of your workspace's named routers.
tools[] are your own functions: Stav returns the call the model
wants to make and your application executes it. Stav does not run
tools server-side.
Header parameters
X-Stav-Runs-InstringWhere this request may run, as a header:
eu,eea, one ISO 3166 alpha-2 country code, or a comma-separated list of codes (NO, SE). The same values and the same meaning as theprovider.runs_inbody field, for clients that can set fixed headers but not body fields (an SDK'sdefault_headers). It filters the Provider Endpoints that may serve and every failover; when none passes, the request is refused (403 endpoint_not_admissible) and nothing is sent.It only ever narrows. Sent together with
provider.runs_in, both must hold:X-Stav-Runs-In: eeawith"runs_in": "NO"runs in Norway;X-Stav-Runs-In: euwith"runs_in": "NO"or"US"has no country in common and is400 invalid_value. It never widens your workspace policy. A value Stav cannot read, an empty one, or two header lines with different values is400 invalid_valuewithparamX-Stav-Runs-In; the same value sent twice counts once. The request log shows the region with its source.GET /v1/modelslists only models with an endpoint inside it, and a Router orautoonly when at least one of its candidates has one (without a key,autois not listed under the header);GET /v1/models/{model_id}/endpointslists only those endpoints, andGET /v1/models/{model_id}gives their limits and price./v1/messages/count_tokensreads it too: when the provider's own counter is outside it, the count is a local estimate and the prompt is never sent. The response headerX-Stav-Token-Count(andstav_token_countin the body) saysexact,estimate(the model's own tokenizer, run by Stav) orapproximate(no tokenizer for the model: characters / 4). Reading or cancelling a stored response (GET /v1/responses/{id},/input_items,/cancel) held by an endpoint outside it is refused with403 endpoint_not_admissible;DELETEis not refused, so data held outside the region can always be erased.X-Stav-Min-Sovereignty-LevelstringThe lowest sovereignty level that may serve this request:
L1,L2,L3orL4, in any letter case.L3admits L3 and L4. The same meaning as theprovider.min_sovereignty_levelbody field, for clients that can set fixed headers but not body fields. It filters the Provider Endpoints that may serve and every failover. An endpoint with no level does not pass. When none passes, the request is refused and nothing is sent.It only ever narrows: the highest of your workspace's floor, the Router's, this header, the body field and a level in the model name (
auto:L3) holds. An empty value, any other value, or two header lines with different values is400 invalid_valuewithparamX-Stav-Min-Sovereignty-Level.A level is a grade, not a place. To keep a request in the EU, send
X-Stav-Runs-In: eutoo. Today only your own Stav Tunnel node is atL4.The model listings,
/v1/messages/count_tokensand stored responses follow it as they followX-Stav-Runs-In.X-Stav-TagsstringName=value pairs for a Decision Router:
tier=free, feature=summarise. At most 16 pairs and 1,024 characters. A name is 1 to 32 ofa-z,0-9,_or-, read in lower case. A value is 1 to 64 printable ASCII characters, with no,or=, compared exactly. A name given twice is an error.Read only by a Decision Router with an X-Stav-Tags request fact. There, a header that breaks these rules answers
400 invalid_caller_labels. Every other Router ignores it. A caller can send any value, so use X-Stav-Tags to sort traffic, never as a control. Not forwarded to an Inference Provider. See Route requests by case.X-Stav-Run-IdstringOptional. Names a run: the requests of one agent task, so Stav can notice an agent that runs away. 1 to 128 printable ASCII characters (space to
~), sent once. Without it, Stav groups requests by the session the routing already uses (session_id,X-Session-Id,prompt_cache_key, else the start of the conversation).Scoped to your workspace and API key: two workspaces sending the same value are two runs. Never sent to an Inference Provider. A malformed value is refused with
400 invalid_run_idwhile Stav tracks runs, and ignored otherwise. It never changes routing.
Request body
modelstringrequiredOne of these forms:
creator/model— a catalogue model; the Smart Router picks the Provider Endpoint among those your policy admits;creator/model/provider— the same model pinned to one Inference Provider, in every region it serves the model from; add the region code to pin one region (…/amazon-bedrock:eu-west-2). A variant that is not a region (:fast) is reached only by naming it. A pin never bypasses your policy: it only narrows the endpoints your policy admits. An endpoint the model lacks is a 404, one your policy excludes is a 403, both by name;- the bare model name (
claude-opus-5) — a convenience alias, accepted when it names exactly one catalogue model; auto— your workspace's default routing policy;@workspace-slug/router-slug— a named router your workspace authored;creator/model/@node— the same model pinned to one of your own Stav Tunnel nodes (@workspace-slug/nodealso works). A model your node serves that is not in the catalogue is named@workspace-slug/local-idand pinned as@workspace-slug/local-id/@node. A pin to a node never fails over; auto and router traffic does.
Any form with no Inference Provider and no node in it may end in one rule, in any letter case:
:euor:eea(the same asprovider.runs_in), or:L1to:L4(the same asprovider.min_sovereignty_level).auto:euis your default Router in the EU only;auto:L3is at sovereignty level L3 or higher. A rule only narrows. A word Stav does not know (auto:ue) or a second rule (auto:eu:L3) is a 404 that names it, and nothing is sent.messagesarray of objectsrequiredShow 5 child fields
roleenumrequiredsystemuserassistanttoolcontentstring | array of objectString for text-only messages, or array of content parts (text, image_url, file, input_audio) for multimodal models.
namestringOptional name for the message author.
tool_call_idstringRequired when role is
tool.tool_callsarray of objectsTool calls the assistant made (assistant-role messages only).
Show 3 child fields
idstringrequiredtypestringrequiredfunctionobjectrequiredShow 2 child fields
namestringrequiredargumentsstringrequiredJSON-encoded argument object.
streambooleanstream_optionsobjectStreaming options, applied only when
stream=true.Show 1 child field
include_usagebooleanWhen true, a final SSE chunk carries a
usageobject with token counts and an emptychoicesarray, before the[DONE]sentinel. Without it a streaming response reports no token counts at all.
nintegerNumber of choices to return. Only
1is supported —n>1returns 400 (unsupported_parameter). Issue parallel requests instead.providerobjectThe
providerobject on the chat surfaces (/v1/chat/completions,/v1/messages,/v1/responses): the fields ofRequestProviderFilter, plusmax_priceandquantizations, which filter the endpoints that may serve — the pick and every failover stay inside them — andsort, which orders a named model's endpoints. When no endpoint passes, the request is refused (403 endpoint_not_admissible, naming the field) and nothing is sent upstream.require_parametersandallow_fallbacksare refused by name (400 unsupported_parameter), as is any other key. On/v1/messagesit is never forwarded to Anthropic. The other surfaces take onlyRequestProviderFilter.Show 8 child fields
runs_instring | array of stringWhere the request may run:
"eu","eea", one ISO 3166 alpha-2 country code, or a list of country codes (["NO", "SE"]). One region or countries, not both in one list.globalendpoints satisfy no region, so most Claude and Gemini endpoints are excluded by"eu". TheX-Stav-Runs-Inheader takes the same values; sent with this field, both must hold.min_sovereignty_levelenumThe lowest sovereignty level that may serve:
"L3"admits L3 and L4. An endpoint with no level does not pass. A level is a grade, not a place: to keep a request in the EU, sendruns_intoo. TheX-Stav-Min-Sovereignty-Levelheader takes the same values; the highest level sent holds.L1L2L3L4regionstring | array of stringAlias of
runs_in, same meaning. Not a provider region code — those are chosen in the model id (creator/model/provider:<code>). Sending both with different values is400 invalid_value.onlyarray of stringOnly endpoints of these Inference Providers serve (slugs, as listed by
GET /v1/models/{model_id}/endpoints). Applies to the endpoint, whoever the model's provider of record is. An unknown slug is400 invalid_value.ignorearray of stringNo endpoint of these Inference Providers serves (slugs).
max_priceobjectThe highest price an endpoint may charge, per 1M tokens, in your workspace's billing currency — the price shown by
GET /v1/models/{model_id}/endpoints. Every rate the request can be billed at without asking for it counts: a conditional rate (a long prompt, an image in or out) and the reasoning output rate. A service tier or prompt-cache write you ask for does not. An endpoint whose price is not known does not pass. An empty object sets no ceiling; any key other thanpromptandcompletionis400 unsupported_parameter.Show 2 child fields
promptnumberInput tokens.
completionnumberOutput tokens.
quantizationsarray of stringOnly endpoints serving one of these quantizations (
fp8,bf16,int4, …; any case). Read from the endpoint, else from the model. An endpoint whose quantization is not known does not pass. An empty list sets no filter.sortenumOrder the endpoints of the model you named.
price: the lowest expected cost of this request first, priced at your workspace's own rates (the rates you are billed at).latency: the lowest time to first token first.throughput: the most tokens per second first. An endpoint with no figure goes last. Failover follows the same order.It only orders the endpoints the other fields and your workspace policy admit; it never adds one. Without
sortStav picks the endpoint by live speed. Withmodel: "auto"or a Router it is400 unsupported_parameter— the Router's objective chooses there.pricelatencythroughput
modelsarray of stringStav extension, reserved for a later release. Accepted on
autoor a Router and has no effect today. With an explicit model it returns 400unsupported_parameter(parammodels).temperaturenumberSampling temperature. Higher is more random. Honoured on: OpenAI, Anthropic, Google, Mistral.
top_pnumberNucleus sampling cutoff. Honoured on: OpenAI, Anthropic, Google, Mistral.
max_tokensintegerMaximum tokens to generate. Honoured on: OpenAI, Anthropic, Google, Mistral.
response_formatobjectStructured-output contract (json_object / json_schema). type grammar is refused (400). Honoured on: OpenAI, Anthropic, Google, Mistral. Requires the
structured_outputcapability — withmodel="auto"this becomes a hard filter on the candidate pool.Show 3 forms
ResponseFormatTexttypestringrequired
ResponseFormatJsonObjecttypestringrequired
ResponseFormatJsonSchematypestringrequiredjson_schemaobjectrequiredShow 4 child fields
namestringrequiredschemarequiredA JSON Schema 2020-12 document.
descriptionstringstrictboolean
toolsarray of objectsFunction/tool definitions the model may call. Hosted tools (any
typeother thanfunctionorcustom, e.g.web_search) are dropped and named inX-Stav-Dropped-Params: no provider on this surface runs them. Honoured on: OpenAI, Anthropic, Google, Mistral. Requires thefunction_callingcapability — withmodel="auto"this becomes a hard filter on the candidate pool.Show 2 child fields
typestringrequiredfunctionobjectrequiredShow 3 child fields
namestringrequireddescriptionstringparametersJSON Schema for the function's arguments.
allowed_toolsarray of string | objectRestrict which of
toolsthe model may call, without changing the tool array — so a mid-loop restriction does not invalidate the prompt cache. The value is passed to the provider as sent. Honoured on: OpenAI. Returns 400unsupported_parameteron: Anthropic, Google, Mistral. Requires thefunction_callingcapability — withmodel="auto"this becomes a hard filter on the candidate pool.tool_choiceenum | objectConstrain which tool the model may call. Honoured on: OpenAI, Anthropic, Google, Mistral. Requires the
function_callingcapability — withmodel="auto"this becomes a hard filter on the candidate pool.Show 1 form
ToolChoiceFunctiontypestringrequiredfunctionobjectrequiredShow 1 child field
namestringrequired
reasoning_effortenumReasoning depth for models that support extended thinking (none, minimal, low, medium, high, xhigh, max).
noneasks a model that reasons by default to stop; it does not require theextended_thinkingcapability. Translated to the nearest level the serving endpoint accepts (ties round down); the level sent is returned inX-Stav-Reasoning-Effort. Honoured on: OpenAI, Anthropic, Google, Mistral. Aliases accepted:reasoning,thinking. Any level other thannonerequires theextended_thinkingcapability — withmodel="auto"this becomes a hard filter on the candidate pool.noneminimallowmediumhighxhighmaxstopstring | array of stringUp to 4 sequences that halt generation. Honoured on: OpenAI, Anthropic, Google, Mistral.
top_kintegerTop-k sampling cutoff. Honoured on: Anthropic, Google. Returns 400
unsupported_parameteron: OpenAI, Mistral.seedintegerBest-effort determinism across identical requests. Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.logprobsbooleanReturn log probabilities for output tokens. Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.top_logprobsintegerMost-likely tokens to return per position (0–20). Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.presence_penaltynumberPenalise tokens already present in the text. Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.frequency_penaltynumberPenalise tokens by existing frequency. Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.logit_biasobjectPer-token likelihood bias map (token id → −100..100). Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.verbosityenumGPT-5 output verbosity hint (low / medium / high). Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.lowmediumhighpredictionobjectPredicted output for latency-optimised edits (OpenAI). Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.prompt_cache_keystringCache-routing hint for OpenAI automatic prompt caching. Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.safety_identifierstringStable end-user identifier for abuse monitoring. Honoured on OpenAI; declared intentional-ignore elsewhere (portable clients send it universally). Honoured on: OpenAI. Declared no-op on: Anthropic, Google, Mistral (accepted and ignored, never a 400).
service_tierenumOpenAI processing tier (auto / default / flex / priority). Billing follows the tier the provider echoes, not the one sent (auto may come back as priority); the request log shows it. A tier the endpoint has no conditional rate for is refused with 400 service_tier_unpriced (the message names the tier); auto is accepted only when every tier the provider may pick is priced (issue #1154 gap 4). Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.autodefaultflexpriorityuserstringStable end-user identifier (legacy; see safety_identifier). Honoured on OpenAI; declared intentional-ignore elsewhere (OpenAI-SDK clients attach it to every request, any provider). Honoured on: OpenAI. Declared no-op on: Anthropic, Google, Mistral (accepted and ignored, never a 400).
parallel_tool_callsbooleanAllow the model to emit multiple tool calls in one turn. Honoured on: OpenAI. Returns 400
unsupported_parameteron: Anthropic, Google, Mistral.min_pnumberMin-p nucleus floor. Provider-specific tuning. Not honoured on any provider — returns 400
unsupported_parameternaming the parameter and the model that resolved.repetition_penaltynumberRepetition penalty. Provider-specific tuning. Not honoured on any provider — returns 400
unsupported_parameternaming the parameter and the model that resolved.storebooleanPersist the completion for later retrieval.
falseis accepted: Stav never persists completions.truewould store your output in Stav's provider account, not yours.truereturns 400unsupported_parameteron every provider, naming the parameter and the model that resolved.session_idstringStav extension — explicit conversation session id (overrides anchor chaining). Also names the routing session: the router uses it to remember what it decided last turn, for sticky routing and warm caches. Namespaced by team and API key before hashing, so two tenants sending
defaultnever share state. Also accepted as theX-Session-Idrequest header; the resolved session is echoed back in theX-Session-Idresponse header. Meant for Stav's router and forwarded to no provider — accepted on every model, never a 400.cost_tierenumStav extension, reserved for a later release. Accepted and checked (an unknown value is a 400), and has no effect today. Meant for Stav's router and forwarded to no provider — accepted on every model, never a 400.
lowbalancedhighmaxremaining_turnsintegerStav extension, reserved for a later release. Accepted and checked (outside 0–1000 is a 400), and has no effect today. Meant for Stav's router and forwarded to no provider — accepted on every model, never a 400.
metadataobjectFree-form keys and values, never forwarded to an Inference Provider. A Decision Router with a request metadata fact reads one top-level key as text, and answers
invalid_request_metadatawhenmetadatais not an object, has more than 16 keys or 8 KB, or holds anything but text of at most 512 characters under a key it checks. Every other Router ignores it. Accepted on every model and forwarded to no provider.modalitiesarray of stringRequested output modalities (e.g. audio). Stav serves text. Not honoured on any provider — returns 400
unsupported_parameternaming the parameter and the model that resolved.include_reasoningbooleanEcho the reasoning trace in the response. Reasoning is reported as a token count on
usage.completion_tokens_detailsinstead. Not honoured on any provider — returns 400unsupported_parameternaming the parameter and the model that resolved.chat_template_kwargsobjectBackend chat-template arguments. Not honoured on any provider — returns 400
unsupported_parameternaming the parameter and the model that resolved.
Notes
Many gateways accept every parameter and quietly drop the ones the upstream model cannot use. You get a 200 and the setting did nothing.
Stav does the opposite:
A parameter is either honoured, or refused by name with a
400. It is never silently dropped.
If a provider cannot honour a parameter, the request is refused. Where something must be removed to make the request work — a hosted tool no provider runs, or a cache marker on the translation path — the response names it in X-Stav-Dropped-Params.
This page covers /v1/chat/completions, where the contract is enforced by one parameter registry. /v1/messages and /v1/responses are covered at the end.
What a refusal looks like
{
"error": {
"message": "Parameter 'logit_bias' is not supported by provider 'anthropic'. Remove it or route to a model/provider that supports it.",
"type": "invalid_request_error",
"param": "logit_bias",
"code": "unsupported_parameter",
"request_id": "chatcmpl-…",
"docs_url": "https://stav.ai/docs/api/errors#request-validation"
}
}
When the limit belongs to the model rather than the provider — stop on an OpenAI GPT-5 or o-series model, for example — the message names the model, and the router and model you asked for if they differ:
Parameter 'stop' is not supported by model 'gpt-5-5'. Remove the parameter, or address a
model served by a provider that supports it (anthropic, google, mistral, openai).
A field the request schema does not know is also a 400 naming the field.
Discover before you send
GET /v1/params— the registry as JSON: every parameter, its description, the dialects that honour it, and the capability it needs. Anonymous, no key required.GET /v1/models/{id}—stav_capabilitiesfor one model (tool_use,vision,structured_output,extended_thinking, …) andstav_supports_thinking.
curl https://api.stav.ai/v1/params
curl https://api.stav.ai/v1/models/anthropic/claude-sonnet-4-5 \
-H "Authorization: Bearer $STAV_API_KEY"
When you route with model="auto" or a Router, the capabilities your request needs (tools, images, a schema, reasoning) become hard filters on the candidate pool.
Dialects, not providers
Support is keyed by wire dialect:
| Dialect | Backs |
|---|---|
openai | OpenAI and every OpenAI-compatible Inference Provider (xAI, Fireworks and others) |
anthropic | Anthropic |
google | Gemini |
mistral | Mistral |
The table
Legend: ✅ honoured · 400 refused by name · ignored accepted and not forwarded, by design
model, messages, stream and stream_options are request structure, not parameters. stream_options.include_usage is honoured on every dialect.
| Parameter | openai | anthropic | mistral | Notes | |
|---|---|---|---|---|---|
temperature | ✅ | ✅ | ✅ | ✅ | Left out, and named in X-Stav-Dropped-Params, where the Provider Endpoint accepts only the default (for example OpenAI GPT-5 and o-series models). Also left out on Anthropic while reasoning is active, and on Anthropic when a non-default top_p is also set, because the provider rejects both together |
top_p | ✅ | ✅ | ✅ | ✅ | Left out, and named in X-Stav-Dropped-Params, where the Provider Endpoint accepts only the default. On Anthropic, sent only when non-default |
max_tokens | ✅ | ✅ | ✅ | ✅ | Sent as max_completion_tokens where the Provider Endpoint wants that name. Anthropic gets 4096 when unset. Above the Provider Endpoint's own output limit, it is lowered to that limit and named in X-Stav-Clamped-Params — see below |
max_completion_tokens | ✅ | ✅ | ✅ | ✅ | The same cap as max_tokens — send either. Both with different values is a 400 |
stop | ✅ | ✅ | ✅ | ✅ | Anthropic receives stop_sequences. 400 where the Provider Endpoint refuses it (for example OpenAI GPT-5 and o-series models). Stav does not enforce a count; providers do (OpenAI: 4) |
tools | ✅ | ✅ | ✅ | ✅ | Needs the tool-use capability. Hosted tools are dropped — see below |
tool_choice | ✅ | ✅ | ✅ | ✅ | |
allowed_tools | ✅ | 400 | 400 | 400 | Restricts which tools may be called without changing the array, so the prompt cache survives |
parallel_tool_calls | ✅ | 400 | 400 | 400 | |
response_format | ✅ | ✅ | ✅ | ✅ | text, json_object, json_schema, grammar. Needs the structured-output capability |
reasoning_effort | ✅ | ✅ | ✅ | ✅ | none, minimal, low, medium, high, xhigh, max. reasoning and thinking are accepted aliases. Moved to the nearest level the endpoint accepts (ties go lower); the level sent is in X-Stav-Reasoning-Effort. See Reasoning |
top_k | 400 | ✅ | ✅ | 400 | |
seed | ✅ | 400 | 400 | 400 | |
logprobs | ✅ | 400 | 400 | 400 | |
top_logprobs | ✅ | 400 | 400 | 400 | 0–20 |
presence_penalty | ✅ | 400 | 400 | 400 | |
frequency_penalty | ✅ | 400 | 400 | 400 | |
logit_bias | ✅ | 400 | 400 | 400 | |
verbosity | ✅ | 400 | 400 | 400 | low / medium / high |
prediction | ✅ | 400 | 400 | 400 | Predicted outputs |
prompt_cache_key | ✅ | 400 | 400 | 400 | Also used as a session identity for routing |
service_tier | ✅ | 400 | 400 | 400 | |
user | ✅ | ignored | ignored | ignored | SDKs send it everywhere, so it is not refused |
safety_identifier | ✅ | ignored | ignored | ignored | Same reason |
store | — | — | — | — | false is honoured (Stav never stores completions). true is a 400: it would store your output in Stav's provider account, where you cannot reach or delete it |
n | — | — | — | — | 1 only. n > 1 is a 400 — send parallel requests |
min_p | 400 | 400 | 400 | 400 | Not supported. Ask if you need it |
repetition_penalty | 400 | 400 | 400 | 400 | Not supported. Ask if you need it |
metadata | Stav | Stav | Stav | Stav | Accepted and never forwarded. A Decision Router with a request metadata fact reads it |
modalities | 400 | 400 | 400 | 400 | Text output only |
include_reasoning | 400 | 400 | 400 | 400 | Reasoning tokens are reported in usage.completion_tokens_details |
chat_template_kwargs | 400 | 400 | 400 | 400 |
Stav extensions
Read by Stav, never forwarded to a provider.
| Parameter | Meaning |
|---|---|
session_id | Your conversation id (≤128 chars). Keeps routing sticky across turns. The resolved session comes back in X-Session-Id |
provider | runs_in, min_sovereignty_level, only, ignore, max_price, quantizations — each one filters the endpoints that may serve, on a model you name and on auto or a Router. When no endpoint passes, the request is refused (403 endpoint_not_admissible on a named model, 404 no_eligible_models on auto or a Router) and nothing is sent. sort orders a named model's endpoints and is a 400 unsupported_parameter on auto or a Router. require_parameters and allow_fallbacks always are |
X-Stav-Runs-In (header) | provider.runs_in as a header — eu, eea, a country code or NO, SE — for SDKs that set fixed headers. Sent with provider.runs_in, both must hold; nothing in common is a 400 invalid_value with param X-Stav-Runs-In |
X-Stav-Min-Sovereignty-Level (header) | provider.min_sovereignty_level as a header — L1, L2, L3 or L4. Sent with the body field or a level in the model name, the highest holds |
| A rule after the model name | auto:eu, auto:eea, auto:L1 to auto:L4, also on a Router or a named model with no Inference Provider in its id: the same two rules, for an app with only a model box |
See Routing hints. models, cost_tier and remaining_turns are reserved for a later release: they are accepted and have no effect today (models with a named model is a 400 unsupported_parameter).
Refused by name. These parse, but nothing honours them, so each returns 400 unsupported_parameter with param set to the field: provider.require_parameters, provider.allow_fallbacks, and response_format with type: "grammar".
Dropped, and named
Four things are removed rather than refused, because leaving them in would break the request.
Sampling a model does not take. Some Provider Endpoints accept only the default temperature and top_p. Stav measures this per endpoint, from the provider's own error. A non-default value there is left out and named in X-Stav-Dropped-Params, so SDK defaults such as temperature=0.7 keep working.
A reasoning level on a model that does not reason. On /v1/chat/completions, when you name a model that cannot reason, reasoning_effort (or reasoning / thinking) is left out and named in X-Stav-Dropped-Params. The answer is the same either way: the model does not think. Many agents send a level on every request, so this keeps them working on every model. none is never named — it asks for no reasoning, which the model already does. With auto or a Router, a level still limits the choice to models that reason; see Reasoning.
Hosted tools. Tools that ask the server to run something (web_search, file_search, code_interpreter, Anthropic's web_search_20250305, bash_20250124, …) are not run by any provider behind these surfaces. They are dropped and named in X-Stav-Dropped-Params:
/v1/chat/completions: every tool whosetypeis notfunctionorcustom./v1/messageswith a non-Claude model: every tool whosetypeis notcustom./v1/responseswith a model served through translation: hosted tools such asweb_search.
If tool_choice points at a dropped tool, it is dropped too.
No tool left. "tools": [] means no tools, and several Inference Providers refuse an empty list, or a tool_choice sent without tools. So when a request ends up with no tool (an empty list, a list of hosted tools only, or no tools at all), what needs tools is left out and named in X-Stav-Dropped-Params:
/v1/chat/completions: the empty list itself (astools), anytool_choice,parallel_tool_callsandallowed_tools./v1/responseswith a model served through translation: anytool_choice. The empty list is left out without being named./v1/messageswith a non-Claude model: anytool_choice, with thedisable_parallel_tool_useit carries. The empty list is left out without being named.
cache_control. It sits inside messages, tools and the system prompt:
| Provider | Behaviour |
|---|---|
| Anthropic | Honoured, including on /v1/chat/completions |
| Removed — Gemini's OpenAI-compatible API rejects the key | |
| OpenAI, xAI, Mistral | Ignored; they cache automatically |
On /v1/messages with a non-Claude model it is dropped and named in X-Stav-Dropped-Params.
Moved, and named
A system message later in a conversation joins the first system message, in order. The same applies to a developer message. Providers handle a later system message differently: some lose it with no error, and some refuse the request. So Stav sends every system message at the top, for every provider.
The moved message then applies to the whole conversation. If an earlier user message conflicts with it, the answer can change. X-Stav-System-Messages-Moved gives the number of messages that moved. Several system messages already at the top also join into one, and that does not set the header. It does not change what they apply to.
Lowered, and named
max_tokens above the Provider Endpoint's output limit. max_tokens is a ceiling, and some Provider Endpoints have a lower one — Scaleway serves GLM-5.2 with at most 16,384 output tokens. Stav sends the endpoint's own limit instead and names it in X-Stav-Clamped-Params, for example max_tokens=16384. The answer is the one the provider would give at its own limit. When Stav does not know the limit yet, it learns it from the provider's refusal and retries once at the stated limit; later requests are lowered before the call. A context-length error is not an output limit and is never read as one.
Other surfaces
/v1/messages. Claude models are proxied to Anthropic as sent; unknown fields are forwarded, not refused. Other models are translated onto the chat path: thinking becomes reasoning_effort, and the chat-completions rules above apply. session_id and provider are accepted here too. provider follows the chat-completions rules on every model, including Claude, and is never forwarded to Anthropic.
/v1/responses. OpenAI models are proxied as sent. Other models are translated onto the chat path. store: true is refused (403 store_not_permitted) when your workspace requires zero data retention.
/v1/audio/transcriptions. A multipart/form-data request with its own short list: file, model, language, prompt, response_format, temperature. The same contract applies — any other field, and stream, is refused by name with 400 unsupported_parameter. auto and Routers are refused (router_not_supported). See Audio transcriptions.
Streaming and errors
A refusal found before dispatch is a normal 400. An error after a stream has opened arrives as an SSE error frame followed by a chunk with finish_reason: "error" — the status line already said 200. Check every frame. See Errors.
Response headers
| Header | Meaning |
|---|---|
X-Stav-Request-Id | Unique request identifier, identical to the completion |
X-Stav-Model | The model that actually served the request — not necessarily the one you asked for, when routing or failover intervened. |
X-Stav-Provider | The Inference Provider that served the request. On a streaming
response it names the first endpoint tried: the headers go out
before the first byte, so after a failover read |
X-Stav-Sovereignty-Level | The effective sovereignty level (L0–L4 ladder) of the endpoint
that served this request. |
X-Stav-Route-Reason | One-line, human-readable rationale for the selection. Present on pinned requests too, where it restates the selection. Prose — do not parse it; the structured decision is in the routing log. |
X-Stav-Router | The named or default router that handled the request, when one did. |
X-Stav-Served-By |
|
X-Stav-Node-Id | The id of your Stav Tunnel node that served (with |
X-Stav-Route-Time-Ms | On a streaming response, time from handler start to provider dispatch. On a non-streaming response, total handler latency including the provider round-trip. The two are not comparable. |
X-Stav-Reasoning-Effort | Present when the request carried a reasoning control
( |
X-Stav-Reasoning-Chosen-By | Who chose the reasoning level the provider received: |
X-Stav-Upstream-Surface | The provider API that served the request: |
X-RateLimit-Limit | Per-minute request cap on this key. |
X-RateLimit-Remaining | Requests remaining in the current window. |
X-RateLimit-Reset | Unix timestamp (seconds) when the current window rolls over. |
Errors
| Status | When |
|---|---|
| 400 | Invalid request — malformed JSON, missing required fields, or invalid parameter values. |
| 401 | Missing or invalid API key. |
| 403 | The API key lacks the required scope, or a Decision Router matched a case that blocks the request ( |
| 404 | Model id is not in the catalogue, or the caller's key doesn't have access to it. |
| 429 | Per-key or per-IP rate limit exceeded. |
| 502 | An upstream provider (Anthropic, OpenAI, etc.) returned an error. |
Every error code, what it means and what to do: Errors.