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-parametre
X-Stav-App-IdstringOptional app slug for attribution on the inference log.
Anmodning
modelstringpåkrævetmax_tokensintegerpåkrævetmessagesarray of objectspåkrævetVis 2 underfelter
roleenumpåkrævetuserassistantcontentstring | array of objectpåkrævet
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 7 underfelter
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".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.Vis 2 underfelter
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 underfelter
namestringpåkrævetinput_schemapåkrævetJSON Schema 2020-12 document for the tool's input.
descriptionstringcache_controlobjectVis 1 underfelt
typestring
tool_choiceobjectVis 3 former
Form 1typestring
Form 2typestring
Form 3typestringpåkrævetnamestringpåkrævet
thinkingobjectExtended thinking config (Anthropic models only).
Vis 2 underfelter
typeenumenableddisabledbudget_tokensinteger
metadataobjectVis 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 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: |
Fejl
| Status | Hvornår |
|---|---|
| 400 | Invalid request — malformed JSON, missing required fields, or invalid parameter values. |
| 401 | Missing or invalid API key. |
| 403 | API key lacks the required scope (e.g., |
| 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 fejlkoder, hvad de betyder, og hvad du skal gøre: Fejl.