Skip to main content

Models

A model is the name a client sends in the model field. It can match a vendor name (gpt-4o) or be your own alias (chat-default, coding-fast). Each model has its own routing, fallback, context, guardrail, logging and pricing settings. Clients only see and use the models they are granted.

Open AI Gateway › Models and select Add model or a model name. The editor has six tabs.

General​

FieldMeaning
Model nameWhat clients send. Letters, digits and . _ : / @ -, up to 128 characters, unique.
Display name, descriptionShown in /v1/models and to developers.
KindChat (/v1/chat/completions, /v1/responses, /v1/messages), Embeddings (/v1/embeddings), Images (/v1/images/generations) or Audio (/v1/audio/speech, /v1/audio/transcriptions). A model can only be called on the endpoints of its kind.
TagsClients can be granted every model with a tag (tag:coding).
CapabilitiesInformational: chat, tools, vision, streaming, reasoning, json.
ActiveInactive models return 404 model_not_found. The switch on the Models list toggles this too.
ListedUnlisted models still work for granted clients but are hidden from GET /v1/models.

Deployments and routing​

A deployment is a provider plus the model name that provider expects (the upstream model), for example Azure EU › gpt-4o-2024-08-06. A model can have several. The list order sets priority: the top row is the primary.

StrategyHow a deployment is picked
PriorityIn list order; later rows are only used as fallbacks
WeightedRandomly, in proportion to each deployment's weight
Lowest latencyFastest recent average latency first
Lowest costCheapest by the model's pricing first
Least busyFewest requests in flight first

Deployments on inactive providers, or on providers without every required region tag, are never used.

Fallback​

With Fallback enabled, a failed call is retried on the next deployment, then on the fallback models in the order you pick them. With it off, the first error is returned to the client.

SettingMeaning
Fall back whenWhich failures move on: provider errors (5xx) and connection failures, rate limited (429), timeout, key rejected (401/403), provider content filter, prompt too long for the target. Other errors (such as a 400 for a malformed request) are returned immediately.
Max attemptsTotal attempts across deployments and fallback models (0 = try every target).
Retries per targetExtra tries on the same deployment before moving on, with retry backoff between them.
Cool down after failures / forAfter this many consecutive failures, a deployment is skipped for this many seconds. If every deployment is cooling down they are still tried.
Then try these modelsOther models of the same kind, used after this model's deployments. The client must also be granted them.

Responses carry X-LLM-Provider and X-LLM-Model (who served the request) and X-Zerq-Fallback: <n> when n attempts failed first. Each attempt is listed in the AI log.

Context​

SettingMeaning
Context window, max input tokensPrompt size limit (estimated from text length). 0 uses the context window; both 0 means no check.
When a prompt is too longReject with 400 context_length_exceeded (default), Trim the oldest messages while keeping system messages and the latest message, or Send to a larger model.
Default max_tokensApplied when the client sends none.
max_tokens capLarger requested values are lowered to this.
System promptLeave the client's system prompt as is, prepend yours, or replace it.
Default parametersJSON object applied when the client does not send a value, e.g. {"temperature": 0.2}.
Locked parametersJSON object that always overrides the client's values.

Guardrails and logging​

Pick a guardrail profile, or leave it empty to use the default from AI Settings. Logging controls what the AI log stores: prompts and completions with personal data masked, or metadata only (tokens, cost, latency, no text).

Pricing​

Prices in USD per million input, output and cached input tokens drive cost in AI Logs and spend limits in AI Budgets. Fill from list prices copies indicative prices for known upstream models; check them against your contract. When pricing is left at 0, the built-in list price for the serving deployment is used if one is known.

Response cache​

On the Pricing & cache tab, a model can reuse earlier answers:

ModeMatches
OffNever (default).
ExactThe same request (messages, tools and parameters; stream, user and metadata are ignored).
SemanticThe same request, or a prompt whose embedding is at least Similarity (0–1, default 0.95) close to an earlier one. Pick an embedding model (a model of kind Embeddings) to compute prompt embeddings.

Answers are cached per client and model, so one client never receives another client's answer, and kept for the TTL (default 1 hour). Only complete text answers are stored: tool calls and answers cut off by max_tokens are not. A cached answer is returned with X-Zerq-Cache: hit (streamed requests receive it as one chunk), is logged with Cache hit in AI Logs, and is not charged tokens or cost (it still counts toward requests per minute). Input guardrails run before the cache, so a blocked prompt is never answered from it.

With Redis/KeyDB configured, exact and semantic entries are shared by all gateway instances (semantic: the newest 500 per client and model); without it, each instance keeps its own in memory. Embedding calls for semantic matching are not charged to the client's budget.

Who can use a model​

A model is usable by a profile only if the profile's client grants it (by name, tag or All models) and, when the profile has its own subset, the subset includes it. See Access and AI keys.