Contact
Skip to the page text

Documentation / Guides / Inference API

API Overview

Every deployed model is served through the API gateway. You call the gateway, not the engines. The examples in these API pages use the placeholder base URL https://<platform-address> and a placeholder key. The API gateway answers over HTTPS only, by default on port 443, with a certificate from the control plane's root CA (see Trusting the control plane in your browser). Your platform's real endpoint, your API gateway keys, and per-model curl examples are shown on the APIs page (/apis) in this app. For interactive use, the Playground page (/playground) sends real requests through this same gateway.

Endpoints

MethodPathWhat it does
POST/v1/chat/completionsChat completions, OpenAI schema
POST/v1/messagesChat messages, Anthropic schema
GET/v1/modelsList models callable through the OpenAI-schema route
ANY/<prefix>/...Passthrough APIs of non-LLM services (OCR etc.), routed by path prefix, see Passthrough APIs

GET requests to other paths under /v1/ return 404. POST requests to other /v1/ paths are forwarded to the engine unchanged -- the model name in the body selects the route, so an engine operation the table does not name (for example /v1/embeddings) is reachable when the engine serves it.

Which replica answers

A model deployed with several replicas answers through all of them. For chat requests (/v1/chat/completions, /v1/completions, /v1/messages) the API gateway prefers the replica that recently served the same beginning of a prompt -- a shared system prompt, the earlier turns of a conversation, the steps of an agent -- because that replica can reuse the work it already did, and it avoids replicas with a long queue. Other requests go to any replica of the model.

You do not choose the replica and do not need to: send the same system prompt and conversation history the same way each time, and repeated prompts get faster. This only helps models whose deploy profile has prefix caching on. If the API gateway cannot make this choice for a while, it spreads requests across the replicas instead: models keep answering, repeated prompts are slower, and the ApiGatewayReplicaSelectionFallback alert names an error report with the cause. How the choice works, and how to write prompts that benefit: How the Gateway Chooses a Replica.

One path, one schema

/v1/chat/completions is always parsed as an OpenAI chat completion. /v1/messages is always parsed as an Anthropic Messages request. The path selects the schema. No header changes it.

Authentication

All endpoints (except health) require an API gateway key. A key starts with onprem-gw-. Send it in one of two headers:

Authorization: Bearer onprem-gw-your-key
x-api-key: onprem-gw-your-key

OpenAI clients send the first header and Anthropic clients send the second. Both work on every path. When a request has both, the gateway reads Authorization.

A missing, unknown, or revoked key returns HTTP 401. An unreachable key database returns 503. Keys are created and shown on the APIs page (/apis).

The anthropic-version header is optional. If it is present and not 2023-06-01, the gateway logs a server-side warning and processes the request anyway. It never rejects on the version.

Error envelope

Errors from the gateway itself use one JSON envelope. OpenAI-schema paths:

{"error": {"message": "...", "type": "...", "code": "..."}}

Anthropic-schema paths (/v1/messages) use the Anthropic error shape instead. The code field names the refusal:

codeWhen
no_such_routeThe API gateway has no route for the request: no deployed model has that name, the path is not one of the gateway's paths, or a debug path names a port the model does not answer on (HTTP 404). The answer comes from the API gateway, not from a model.
model_not_availableThe model is deployed, but no running replica of it can take the request now (HTTP 503; retry)
invalid_request_errorThe body is not valid for the route
request_too_largeThe request body is above the limit (HTTP 413)
ttft_deadline_exceededA streamed request produced no first token within the deadline (HTTP 503, Retry-After: 2)
concurrency_budget_exceeded, kv_cache_utilization_exceededDefined in the gateway's error vocabulary; not enforced today
upstream_failureThe engine returned an error, or was unreachable
missing_api_key, invalid_api_key, revoked_api_keyThe key is missing, unknown, or revoked (HTTP 401)
auth_unavailableThe key database could not be reached (HTTP 503)

Overload refusals are 503, not 429. They carry a Retry-After header -- back off instead of hot-retrying.

Passthrough API responses are the exception: the backend service's status code and body are returned verbatim (see Passthrough APIs).

For the full refusal behavior and client guidance, see How the Gateway Refuses Work.

Found a mistake, or is something missing? Suggest an improvement to this page on GitHub.

Platform release 5.10.4, . Source of this page at v5.10.4. This page as Markdown.