Create a message (Anthropic-compatible)
https://api.stav.ai/v1/messagesAnthropic Messages API. Drop-in for the official Anthropic SDK —
set base_url="https://api.stav.ai" (the SDK appends /v1) and
api_key=sk_stav_live_....
Routing:
anthropic/claude-*models are proxied verbatim toapi.anthropic.com. Full Messages-API fidelity includingcache_controlmarkers, extendedthinking, and beta features.- Every other catalogue model is translated to the OpenAI Chat Completions
contract and dispatched through the same path as
/v1/chat/completions.model="auto"invokes the Smart Router.
Per-key rate limits apply. App attribution via the X-Stav-App-Id
header is supported and recorded on the inference log.
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./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-Countsaysexactorestimate. 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-App-IdstringOptional app slug for attribution on the inference log.
Request body
modelstringrequiredmax_tokensintegerrequiredmessagesarray of objectsrequiredShow 2 child fields
roleenumrequireduserassistantcontentstring | array of objectrequired
systemstring | array of objecttemperaturenumbertop_pnumbertop_kintegerstreambooleanstop_sequencesarray of stringproviderobjectThe
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 7 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.regionstring | 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
toolsarray of objectsTool definitions. On a non-Claude model, server tools (any
typeother thancustom, e.g.web_search_20250305) are dropped and named in theX-Stav-Dropped-Paramsresponse header, together withtool_choicewhen it pointed at one. Tools with aninput_schemaare passed on.Show 4 child fields
namestringrequiredinput_schemarequiredJSON Schema 2020-12 document for the tool's input.
descriptionstringcache_controlobjectShow 1 child field
typestring
tool_choiceobjectShow 3 forms
Form 1typestring
Form 2typestring
Form 3typestringrequirednamestringrequired
thinkingobjectExtended thinking config (Anthropic models only).
Show 2 child fields
typeenumenableddisabledbudget_tokensinteger
metadataobjectShow 1 child field
user_idstring
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 provider that served the request. |
X-Stav-Sovereignty-Level | The effective sovereignty level (L0–L4 ladder) of the endpoint
that served this request. |
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: |
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. |
| 503 | Upstream Anthropic credential not configured on this deployment. |
Every error code, what it means and what to do: Errors.