Skip to main content
User guide

API reference

Authentication for the gateway's client endpoints, request and response headers, what each endpoint does and its limits, streaming and usage accounting, model name resolution, and the error format.

The gateway serves OpenAI- and Anthropic-compatible endpoints under /v1. Apart from the model field, request bodies are passed to the upstream largely unchanged; when the upstream speaks a different format from the client, the gateway translates requests and responses.

Authentication

MethodHeader
BearerAuthorization: Bearer sk-rst-...
Anthropic stylex-api-key: sk-rst-...

Both work on every /v1 endpoint. Without an active licence, every endpoint returns 403 license_required.

Endpoints

MethodPathFormatDescription
POST/v1/chat/completionsOpenAIChat completions, with streaming and tool calls
POST/v1/responsesOpenAI ResponsesServed as a chat completion; see below
POST/v1/messagesAnthropic MessagesStreaming and tool calls; errors in Anthropic format
POST/v1/completionsOpenAIText completions
POST/v1/embeddingsOpenAIEmbeddings; needs an embedding model
POST/v1/rerankvLLMRerank; needs a suitable model
POST/v1/scorevLLMRelevance scoring; needs a suitable model
GET/v1/modelsOpenAIModel names and aliases the key may use

Every endpoint applies the same metering, limits, content safety and personal information masking.

GET /v1/models

Returns {"object": "list", "data": [...]}; each id is a public name or alias, sorted by name. If the key is limited to certain models, only those are listed.

POST /v1/messages

For clients that speak the Anthropic format, such as Claude Code. For OpenAI-compatible upstreams such as vLLM, the gateway converts the request to OpenAI format and merges all system content, in order, into one leading message. For Anthropic upstreams, cache-read and cache-write tokens count as input usage. When the model has Forward priority on, the key's priority is passed to vLLM here too.

Errors look like {"type": "error", "error": {"type": "...", "message": "<code>: <message>"}}.

POST /v1/responses

The gateway turns a Responses request into a chat completion and returns the result in Responses format. Streaming events run from response.created through response.output_text.delta and end with response.completed. Any upstream can serve this endpoint. Multi-turn conversations, function calls, namespaced MCP tools and custom-format tools are supported.

The gateway stores nothing, as if store: false were set:

  • previous_response_id, conversation, background and item_reference return 400 unsupported_parameter; send the whole conversation in input.
  • OpenAI-hosted tools such as web search and file search are ignored.
  • instructions and any system and developer messages are merged, in order, into one leading system message.

Request handling

  • Model name: model can be a public name or an alias. An unknown name returns 404 model_not_found; a model the key may not use returns 403 model_not_allowed.
  • Output cap: when the key has a per-request output cap, a larger max_tokens is lowered and a missing one is added.
  • Priority: a priority field in the request body is not passed on; the gateway uses the key's priority, and writes it into the request only when the model has Forward priority on.
  • Streaming: for streamed requests the gateway sets stream_options.include_usage for metering, so the stream ends with an extra chunk carrying usage. If a stream breaks off, tokens are estimated from what was generated.
  • Body size: up to 32 MB; larger bodies get 413 body_too_large.
  • Routing: fallback models take over on queue timeout, when all upstreams are unavailable or answer 5xx; the long-context model takes over when the context length would be exceeded. See Models.

Response headers

HeaderDescription
X-Request-IdOn every response; matches the request log entry
X-PII-MaskedNumber of replacements when personal information masking is set to mask and continue
Retry-AfterOn 429 responses, value 1

Error format

Errors from the OpenAI-compatible endpoints:

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

Callers should branch on error.code. The full list is under Error codes. Requests the gateway rejects (rate limits, budgets, disallowed models, queue timeouts and so on) are still written to the request log; requests with an invalid key are not.

Console management API

The console's /api endpoints are available to external systems for automation, for example to pull usage reports, authenticated with an API token as Authorization: Bearer fab_...; see API tokens. Download the specification from the Integration Guide page or fetch GET /api/openapi.yaml.

On this page