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
| Refusal | What happened | Error code |
|---|---|---|
| First-token deadline | A 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 route | No 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 replica | The model is deployed, but no running replica of it can take the request now. HTTP 503; retry. | model_not_available |
| Request too large | The request body is above the limit. | request_too_large |
| Response too large | The response is above the limit. The stream is cut. | (stream error) |
| Upstream failure | The engine returned an error, or was unreachable. | upstream_failure |
| Bad request | The body is not valid JSON for the route. | invalid_request_error |
| Auth refusal | The 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
- Read the
codefield in the error body. It names the refusal. - Honor
Retry-After. Retry with backoff and jitter. - On
model_not_available, check that the model is deployed and ready before you retry. - On
request_too_large, send less data. The request limit is 16 MiB. - Declare a small
max_tokenson 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.