Contact
Skip to the page text

Documentation / Concepts

How the Gateway Refuses Work

An LLM engine's real capacity limit is GPU memory for the KV cache, measured in tokens, not requests. One 100k-token request can cost more than fifty 2k-token requests. When too much work is admitted, everything degrades at once: time-to-first-token explodes for every client.

The API gateway therefore rejects fast instead of queueing. A rejected request costs the client one cheap retry. An over-admitted request costs every client seconds of latency.

What the Gateway Enforces Today

RefusalWhat happenedError code
First-token deadlineA streamed request produced no first token within the deadline. The gateway drops it and stops the engine generating for nobody.ttft_deadline_exceeded
No such routeNo deployed model has the name, the path is not one of the API gateway's paths, or a debug path names a port the model does not answer on. HTTP 404 from the API gateway; a retry does not help.no_such_route
No routable replicaThe model is deployed, but no running replica of it can take the request now. HTTP 503; retry.model_not_available
Request too largeThe request body is above the limit.request_too_large
Response too largeThe response is above the limit. The stream is cut.(stream error)
Upstream failureThe engine returned an error, or was unreachable.upstream_failure
Bad requestThe body is not valid JSON for the route.invalid_request_error
Auth refusalThe key is missing, unknown, revoked, or the auth check could not run.missing_api_key, invalid_api_key, revoked_api_key, auth_unavailable

The first-token deadline grows with the size of the request: at least 10 seconds, about 5 minutes for a half-megabyte prompt, and never more than 10 minutes. First-token and no-replica refusals return HTTP 503 with a Retry-After: 2 header. A too-large request returns 413. Back off instead of hot-retrying.

The error vocabulary also defines concurrency_budget_exceeded and kv_cache_utilization_exceeded. The gateway does not enforce these limits today: a model's engine decides how many requests it runs at once and queues the rest. A client must not design around them.

Long Requests

A request may take up to 10 minutes, and the gateway keeps it alive while the model works. What a client sees on each limit, and what a proxy or load balancer in front of the gateway must allow, is in Long Requests and Timeouts.

How a Client Should React

  1. Read the code field in the error body. It names the refusal.
  2. Honor Retry-After. Retry with backoff and jitter.
  3. On model_not_available, check that the model is deployed and ready before you retry.
  4. On request_too_large, send less data. The request limit is 16 MiB.
  5. Declare a small max_tokens on every request. A smaller declared value lets the model serve more requests in parallel.

Where the Numbers Appear

The gateway counts every refusal in its metrics, one series per reason: onprem_ai_api_gateway_rejections_total. The Usage page and the APIs page show request and token usage per model and per API gateway key.

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.