Create embeddings
https://api.stav.ai/v1/embeddingsGenerates vector embeddings for one or more inputs. Drop-in for the OpenAI SDK.
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.
Request body
modelstringrequiredinputstring | array of stringrequiredencoding_formatenumfloatbase64dimensionsintegerTruncate to this many dimensions (Matryoshka-style). Sent only to a Provider Endpoint measured to honour it; refused by name (400 unsupported_parameter) when none does.
userstringproviderobjectStav extension, region per request. Narrows where this one request may run and which Inference Providers may serve it, on top of your workspace policy — it can only narrow, never widen. It filters Provider Endpoints: the serving endpoint and every failover stay inside it, and when no endpoint of the model passes, the request is refused (
403 endpoint_not_admissible, orprovider_blockedwhen every endpoint is on a provider you named inignore) and nothing is sent. A provider pinned in the model id (creator/model/provider) that the filter excludes is400 invalid_valuewithparamprovider.Any other key is refused by name (
400 unsupported_parameter,paramprovider.<key>). Never forwarded to a provider.Show 5 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).
Notes
POST https://api.stav.ai/v1/embeddings takes the same request as OpenAI's embeddings endpoint.
Request
| Field | Type | Notes |
|---|---|---|
model | string | Required. An embedding model from the catalogue. |
input | string or array of strings | Required. Must not be empty. |
encoding_format | float or base64 | Default float. |
dimensions | integer | A shorter vector than the model's native size. Honoured by the Provider Endpoint, not only the model: Stav sends it only to an endpoint that was measured to honour it, and refuses by name (400 unsupported_parameter, param: dimensions) when none of the model's endpoints your workspace can use does. |
user | string | Accepted. |
Any other field is refused by name with 400, as on chat and rerank. It is never dropped. provider is not supported on embeddings yet (400 unsupported_parameter, param: provider): to use one Inference Provider, put it in the model id as creator/model/provider.
Response
{
"object": "list",
"data": [{ "object": "embedding", "index": 0, "embedding": [0.012, -0.034, "..."] }],
"model": "mistral/mistral-embed",
"usage": { "prompt_tokens": 9, "total_tokens": 9, "cost": 0.00000018, "cost_currency": "EUR" }
}
usage.cost is what your wallet is charged for the request, in your workspace's currency (usage.cost_currency), from Stav's own ledger: the input tokens at catalogue price, plus the endpoint's per-request price where Stav charges one. X-Stav-Cost and X-Stav-Cost-Currency carry the same number. When your workspace's own provider key (BYOK) served the call, it is the platform fee alone, or 0 under the free allowance — as on chat. Both fields are absent when the cost could not be quoted; never an estimate.
How it differs from chat
- Name the model.
autoand Routers do not apply; Routers serve the chat surfaces only. - Commercial Inference Providers only. Embeddings are served through provider connectors. A model with no priced Provider Endpoint is refused.
- Your key needs the
inference:embeddingsscope. Without it:403 insufficient_scope. - Billing is the same, plus a per-request price where the endpoint has one. Input tokens are charged at catalogue price. Some embedding endpoints are priced per request instead of, or as well as, per token; that amount is shown on the model page ("€0.001 / request") and charged once per call, from the same tariff, as its own line in your usage. An empty balance blocks paid requests. See Credits and billing.
Errors
| Status | When |
|---|---|
400 | input is empty, or the body has a field not listed above. The message names the field. |
400 unsupported_parameter | provider was sent. Pin the Inference Provider in the model id (creator/model/provider) instead. |
400 unsupported_parameter | dimensions was sent, and no endpoint of the model your workspace can use honours it (or the pinned endpoint does not). Leave it out, or pick another model. |
403 | The key lacks inference:embeddings |
404 model_not_found | The model is not an embedding model, or has no priced Provider Endpoint. The message lists the embedding models available. |
402 | Not enough credits, or a spend limit was reached |
| Provider status | The provider refused the request; its message is passed through as provider_error |
Full catalogue: Errors.
Response headers
| Header | Meaning |
|---|---|
X-Stav-Cost | What the request cost your workspace, in |
X-Stav-Cost-Currency | The workspace's billing currency. Sent with |
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. |
| 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. |
Every error code, what it means and what to do: Errors.