Core reference
Gateway API (/v1)
The OpenAI-compatible and Anthropic-compatible routes a leader serves, how to authenticate, the opod request extensions, and the error codes.
In short
The gateway is the OpenAI-compatible API a leader serves to clients: chat, embeddings, rerank and the model list, plus Anthropic Messages. Any OpenAI SDK works with the base URL http://leader:8080/v1 and an sk-orc-… key. A front door serves the same routes.
curl http://localhost:8080/v1/chat/completions -H "Authorization: Bearer sk-orc-<your-key>" \
-H 'Content-Type: application/json' \
-d '{"model":"auto","messages":[{"role":"user","content":"hi"}]}'The gateway is the part of the leader clients call. A front door (--role gateway) serves the same routes.
Routes
| Method | Path | Notes |
|---|---|---|
GET | /v1/models | The models a request can be answered for now: installed on the leader, or held by a worker that takes new work. A model held only by drained or lost workers is not listed. A model whose workers sleep is listed: a request for it wakes them. |
POST | /v1/chat/completions | OpenAI chat, streamed or not. Tools, tool_choice, response_format and image input. |
POST | /v1/embeddings | OpenAI embeddings, on embedding models. |
POST | /v1/rerank | {model, query, documents, top_n, return_documents} → results, most relevant first, each {index, relevance_score, document.text}. Needs a reranker on vLLM, SGLang or llama.cpp (started with --reranking). |
POST | /v1/messages | Anthropic Messages, translated to the chat path. |
POST | /v1/messages/count_tokens | Anthropic token count. |
Not served: /v1/completions, audio, images generation, files and batches. / answers 404.
With OPOD_VERTEX=1 the leader also serves a Vertex AI custom container: POST AIP_PREDICT_ROUTE (default /v1/vertex:predict; {instances, parameters} → {predictions}, or a chat body passed through) and GET AIP_HEALTH_ROUTE (default /v1/vertex/health). These two take no key, because Vertex authenticates the caller. Each instance is served as its own request; when one fails, the whole predict answers with that instance's status and body, and the header X-Opod-Vertex-Instance names its index. The leader also answers Vertex's gRPC PredictionService on its own port (ChatCompletions, StreamRawPredict, RawPredict).
Authentication
Send the key in one of these forms, checked in this order:
Authorization: Bearer sk-orc-<your-key>
X-Api-Key: sk-orc-<your-key>
?key=sk-orc-<your-key>An Authorization header without the Bearer prefix is taken as the bare key.
Any scope works on /v1. With auth.require_keys: false and no auth snapshot that requires keys, /v1 accepts requests without a key.
| Status | error.type | Cause |
|---|---|---|
401 | missing_api_key | No key in the request. Message: Authorization header required. |
401 | invalid_api_key | Unknown or revoked key. |
401 | key_expired | The key's expiry has passed. |
500 | auth_error | The leader could not read its key store to look the key up. The message carries the store's error. |
503 | — | The policy bounds the auth snapshot's age and the snapshot is older. Retry-After: 30. |
Response headers
| Header | Value |
|---|---|
X-Opod-Request-Id | req_ + 16 hex characters, on every /v1 response. The same id is on the usage row. |
X-Opod-Cache | hit or miss on /v1/embeddings when the response cache is on. |
X-Opod-Fallback | The fallback URL, when the policy's routing.fallbackUrl answered because the leader had no capacity. |
X-Opod-Endpoint | On a cell door's auto route: the alias of the endpoint that answered. |
X-Opod-Session-Route | From core v0.4.3, with the policy's routing.session.signedRoute on: a signed token naming the worker that answered this conversation. Send it back on the next turn (with the same X-Opod-Session) and any front door of the endpoint routes the turn to that worker. A token that does not verify (expired, another model, the worker restarted) is ignored. From core v0.4.7 a gang's answer carries one too: it names the gang and its head worker, and is ignored once the head restarted or the gang re-formed on another head. |
Retry-After | On a 503: when to try again. |
Request extensions
Opod reads these optional extensions. A body field wins over the header.
| Body field | Header | Effect |
|---|---|---|
user (OpenAI) | X-Opod-Session: <id> | From core v0.4.3: the conversation this request belongs to (up to 128 bytes, kept only as a hash). Its turns stay on one worker, apart from the key's other conversations. The header wins over user. |
opod.fallbacks: ["id", …] | X-Opod-Fallbacks: id,id | Models to try, in order, when the primary fails. Replaces the catalog chain for this request. |
opod.num_retries: N | X-Opod-Num-Retries: N | Retry each candidate up to N times. Capped at 5. |
opod.retry_backoff_ms: N | X-Opod-Retry-Backoff-Ms: N | Wait between retries. Capped at 5000. |
opod.hedge: true | X-Opod-Hedge: 1 | Send to several least-loaded workers at once; the first answer wins. Needs router.hedge_replicas above 1 (at most 3). |
opod.sort: "latency" or "throughput" | X-Opod-Sort | Reorder the fallback chain by measured latency or throughput. Unknown values are ignored. |
opod.cache.namespace | — | Scope the response-cache entry (embeddings). |
| — | X-Opod-Class: standard | Lower this request's admission class (critical, standard, sheddable). A request can lower its key's class, never raise it. |
| — | X-Opod-Probe: 1 | Serve the request but count it in no load signal. For health provers. |
| — | Cache-Control: no-cache | Bypass the embeddings response cache. |
A model id ending in :nitro is the same as opod.sort: "throughput". A request that carries overrides is recorded in the audit log.
{
"model": "qwen3-coder-30b",
"messages": [{"role": "user", "content": "hi"}],
"opod": {"fallbacks": ["qwen-coder-14b"], "num_retries": 2}
}Chat completions
- Pass-through. Every body field opod does not model (
seed,logprobs,top_k,user, …) reaches a vLLM, SGLang, llama.cpp or MLX-LM engine unchanged, andlogprobscome back.model,messages,stream,stream_optionsandcache_saltstay opod's. norbest_ofabove 1 is refused400.- Tools.
toolsandtool_choicego to the engine;tool_callscome back, streamed or merged, withargumentsas a string. The next turn's assistanttool_callsand eachtool_call_idgo back to the engine. Opod never runs a tool. vLLM, SGLang and TensorRT-LLM need a tool-call parser, which the worker adds from the catalog'stool_parser. An engine that cannot do tools (Ollama, or an engine started with no parser) refuses with400 unsupported_requestnaming the field. - Structured output.
response_format(json_objectorjson_schema) goes to the engine; for Ollama it becomes Ollama'sformat. - Images.
image_urlcontent parts reach the engine. A model without thevisioncapability, or an engine not proven to take images (SGLang, llama.cpp, MLX-LM), is refused400namingimage_url. - Streaming. Server-sent events. A client that hangs up mid-stream still leaves a usage row with outcome
cancelled. - Cached tokens. From core v0.4.1, the answer's
usagecarriesprompt_tokens_details.cached_tokenswhen the engine reported a prefix-cache count, streamed (in the final chunk) or not, as OpenAI's does. Example:"usage": {"prompt_tokens": 1838, "completion_tokens": 1, "total_tokens": 1839, "prompt_tokens_details": {"cached_tokens": 1824}}. In v0.4.0 the count reaches the usage row only. - Cache isolation. On engines that key their prefix cache by
cache_salt(vLLM, SGLang, TensorRT-LLM), the leader adds a salt per team or per key, according to the policy'srouting.cacheIsolation.
Anthropic Messages
POST /v1/messages works on every chat model. The leader translates it to the chat path and back, so every engine serves it and the usage row says protocol anthropic.
Translated: system, text and base64 image blocks, tool_use, tool_result, tools, tool_choice (with disable_parallel_tool_use), stop_sequences, max_tokens (required), temperature, top_p, top_k, metadata.user_id, and streaming.
Refused with 400 in Anthropic's error envelope: extended thinking, server tools (a tool whose type is not custom), images by URL or file id, document and other block kinds the chat path cannot carry, mcp_servers, container, context_management, and any field the translator does not know.
Model routing
model | Goes to |
|---|---|
| a catalog id | its gang if sharded; else the leader's engine if it holds it; else the least-loaded live worker that does |
auto | the default model (router.default_model) |
| an engine-native name | a node that reports it loaded |
<model>:<adapter> | a LoRA adapter of the model |
<model>:nitro | the model, chain sorted by throughput |
With a plan file, the leader serves its one model (and that model's engine-native aliases and declared adapters). A request for any other model is refused, and the message names the model it serves. An unknown adapter suffix is refused, listing the adapters the plan declares.
Errors
Errors use an OpenAI-style envelope on /v1: {"error": {"message": "…", "type": "…"}}. On /v1, type carries the machine-readable cause (for example model_not_found or worker_unreachable); a cell door adds code and param in OpenAI's exact shape. /v1/messages uses Anthropic's envelope. Branch on type (and code where present), never on the message.
error.type | Status | Cause |
|---|---|---|
invalid_request | 400 | The body is not valid, or a field is missing or wrong. The message names it. |
unsupported_request | 400 | A field the engine cannot serve, named in the message. |
missing_api_key, invalid_api_key, key_expired | 401 | See Authentication. |
model_not_found | 404 | No catalog entry, placement or alias by that name. |
not_found | 404 | A plan-file leader refused another model: this endpoint serves only <model> (requested <other>). |
request_too_large | 413 | The body is over the cap. |
rerank_not_supported, embeddings_not_supported | 501 | The engine has no such route. For embeddings on TensorRT-LLM this arrives from core v0.4.3; v0.4.2 and earlier answer 502 with the engine's 404. |
upstream_error | 502 | The engine was reached and failed, or its stream broke. |
engine_unreachable | 502 | The engine is not reachable; the message carries its name, endpoint and the command to start it. |
upstream_<status>, or the engine's own type | as the engine | The engine answered with a status the caller must see as is (a rate limit, not ready, a bad request); passed through, with Retry-After: 10 on 429 and 503. |
worker_unreachable, gang_unreachable | 503 + Retry-After: 10 | The worker (or the gang's coordinator) picked for the request went away. Retry. |
unavailable | 503 + Retry-After | No capacity now: workers waking, every holder drained, or the admission hold shed the request. |
store_error, encode_error | 500 | An internal failure; the message says which. |
auth_error | 500 | The key lookup failed in the leader's key store. See Authentication. |
Errors the leader writes before a request reaches a handler (the plan check, admission, a malformed body at the dispatcher) carry a type derived from the status: invalid_request (4xx), authentication_error (401), permission_error (403), not_found (404), rate_limit_exceeded (429), unavailable (503), server_error (other 5xx).
By status:
| Status | Meaning |
|---|---|
400 | Bad request, or a field the engine cannot serve (named in the message). |
401 | Missing, invalid or expired key. |
404 | model_not_found. |
413 | request_too_large: the body is over the cap — 32 MiB for chat (max_body_bytes), 8 MiB for embeddings and rerank, 1 MiB for other routes. |
501 | rerank_not_supported on Ollama and MLX-LM. |
502 | The engine failed. engine_unreachable carries the engine name, endpoint and the command to start it. |
503 + Retry-After | No capacity now: workers waking, every holder drained, or the admission hold shed the request. |
Last updated · Source: content/docs/core-reference/gateway-api.mdx · View as Markdown