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-parametere
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.X-Stav-App-IdstringOptional app slug for attribution on the inference log.
Forespørselsinnhold
modelstringpåkrevdThe same forms as on
/v1/chat/completions, a rule after the name included (auto:eu).max_tokensintegerpåkrevdmessagesarray of objectspåkrevdVis 2 underfelt
roleenumpåkrevduserassistantcontentstring | array of objectpåkrevd
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.Vis 8 underfelt
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.Vis 2 underfelt
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.Vis 4 underfelt
namestringpåkrevdinput_schemapåkrevdJSON Schema 2020-12 document for the tool's input.
descriptionstringcache_controlobjectVis 1 underfelt
typestring
tool_choiceobjectVis 3 former
Form 1typestring
Form 2typestring
Form 3typestringpåkrevdnamestringpåkrevd
thinkingobjectExtended thinking config (Anthropic models only).
Vis 2 underfelt
typeenumenableddisabledbudget_tokensinteger
metadataobjectOnly
user_idis forwarded, and only to Anthropic. Every other key is read by a Decision Router with a request metadata fact, or by nothing, and is never forwarded to an Inference Provider.Vis 1 underfelt
user_idstring
Svarheadere
| Header | Betydning |
|---|---|
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-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: |
Feil
| Status | Når |
|---|---|
| 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. |
Alle feilkoder, hva de betyr og hva du gjør: Feil.