Skip to main content

Model API reference

The model API is served under LLM_GATEWAY_PATH (default /llm). It speaks the OpenAI Chat Completions and Responses formats and the Anthropic Messages format, so OpenAI SDKs, Anthropic SDKs, Codex, Claude Code and Cursor work unchanged. Point OpenAI clients at https://<gateway-host>/llm/v1 and Anthropic clients at https://<gateway-host>/llm.

Every format runs through the same pipeline (access, context rules, guardrails, budgets, routing and fallback, logging), and any provider can serve any format: a Claude Code request can be served by an OpenAI deployment and the reverse.

Authenticate with an AI key (Authorization: Bearer zk_... or x-api-key) or with the profile's gateway credentials.

Endpoints​

Method and pathDescription
GET /llm/v1/modelsModels the caller may use (active, listed, granted to the client and in the profile subset).
GET /llm/v1/models/{name}One model. 404 if it does not exist or is not available to the caller.
POST /llm/v1/chat/completionsChat completion in OpenAI format, including tools, images and stream: true (server-sent events). With streaming, send stream_options: {"include_usage": true} to receive token usage in the last chunk.
POST /llm/v1/responsesOpenAI Responses API, used by Codex. Stateless: send the whole conversation in input (store: false); previous_response_id is not supported. Supports instructions, message, function_call and function_call_output items, function tools, custom (free-form) tools such as Codex's apply_patch, text.format JSON schemas and streaming events (response.created ... response.completed). Reasoning items and built-in tools (web search, file search) are ignored.
POST /llm/v1/messagesAnthropic Messages API, used by Claude Code and Anthropic SDKs: system prompts, text and image blocks, tool_use / tool_result, tool choice and streaming events (message_start ... message_stop). Errors use the Anthropic error shape. Thinking blocks and Anthropic server tools are ignored.
POST /llm/v1/messages/count_tokensEstimated input tokens for an Anthropic Messages request.
POST /llm/v1/embeddingsEmbeddings for a string or a list of strings (models of kind Embeddings). Guardrails check and mask the input. Vectors are not stored in AI Logs.
POST /llm/v1/images/generationsImage generation (kind Images); the provider's response is returned as is. Guardrails check the prompt.
POST /llm/v1/audio/speechText to speech (kind Audio); returns the provider's audio (for example audio/mpeg). Guardrails check the input; audio is not logged.
POST /llm/v1/audio/transcriptionsSpeech to text (kind Audio) as a multipart form with model and file. Raise the maximum request size in AI Settings for long recordings.
POST /llm/v1/moderationsModeration with a provider's moderation model (any kind).

Embeddings, images, audio and moderations are served by OpenAI-compatible providers (OpenAI, Azure OpenAI, Groq, OpenRouter, Ollama, Gemini, custom servers; Vertex AI for embeddings where its OpenAI-compatible endpoint offers them). Calling a model on an endpoint of another kind returns 400 invalid_request_error.

model may be omitted when the client has a default model.

Response headers​

HeaderMeaning
X-Zerq-Request-IDID of the AI log entry.
X-LLM-ProviderName of the provider that served the request.
X-LLM-ModelUpstream model that served it.
X-Zerq-FallbackNumber of failed attempts before the one that succeeded (only when a fallback happened).

Errors​

Errors use the OpenAI shape: {"error": {"message": "...", "type": "...", "code": "..."}}.

StatusTypeWhen
400invalid_request_errorBody is not a JSON object, messages is missing, model is missing with no default, or the provider rejected the request as malformed.
400context_length_exceededThe prompt is too long for the model (see context).
400guardrail_blockedA guardrail blocked the prompt or the answer.
400content_filterThe provider's content filter rejected the request.
401authentication_errorMissing or invalid AI key or credentials.
403AI access is not enabled for the profile, or the profile has no authentication.
403model_not_allowedThe model exists but is not granted to this client or profile.
404model_not_foundThe model does not exist or is inactive.
413request_too_largeThe body exceeds the maximum request size in Settings (default 4 MB).
429rate_limit_exceededA per-minute or concurrency limit was reached, or every provider is rate limiting. Includes Retry-After.
429budget_exceededA token or spend quota, or the profile's token cap, is used up. Includes Retry-After.
502upstream_unavailableEvery deployment and fallback model failed.
503gateway_disabledModel traffic is switched off in Settings.
504upstream_timeoutThe providers did not answer within their timeout.

When a stream has already started, an error is sent as a final data: event with the same error object.