HTTP input budgets
Last updated: 2026-11-20T22:49:39-03:00 (UTC-3)
The gateway bounds request headers, request-body reading and idle keepalive connections separately from generating an answer, and asks the operating system for an accept queue of a set length. These listener settings apply at startup; changing the desired policy never changes a running listener. Restart each replica to adopt it.
How to configure it
Section titled “How to configure it”server: read_timeout: 30s read_header_timeout: 5s idle_timeout: 60s listen_backlog: 4096features: ui: true boot_settings_view: trueThis is a partial configuration example. The three durations are consumed by the native HTTP server in every deployment mode; the backlog is consumed by the listener before it is handed to that server.
| YAML parameter | Built-in default | Accepted values | Existing override |
|---|---|---|---|
server.read_timeout |
30s |
5s to 5m |
GATEWAY_HTTP_READ_TIMEOUT |
server.read_header_timeout |
5s |
1s to 1m |
None |
server.idle_timeout |
60s |
1s to 30m |
None |
server.listen_backlog |
4096 |
200 to 65535; raw 0 selects the default |
None |
Omission or an empty duration uses its default; an explicit zero, negative, malformed or out-of-range duration is rejected, including when the view flag is off. Nonempty GATEWAY_HTTP_READ_TIMEOUT overrides the YAML read budget; an empty variable leaves the YAML/default in effect. gateway validate checks YAML and captured environment inputs offline without starting a listener or checking persisted console policy. Errors do not echo the invalid value.
A backlog outside 200 to 65535 (or negative) is rejected the same way; it is not clamped.
Listen backlog (accept queue)
Section titled “Listen backlog (accept queue)”server.listen_backlog is the number of connections the operating system may hold completed but not yet accepted. A burst of simultaneous connects larger than the queue is refused by the kernel before the gateway sees it.
- Windows honors it. Go asks Windows for
SOMAXCONN, which Windows turns into a fixed queue of about 200 pending connections with no system setting to raise it; the gateway therefore listens withSOMAXCONN_HINT(listen_backlog). Measured on Windows Server 2025, a burst of 512 simultaneous connects had 311 refused with the old queue and none withSOMAXCONN_HINT(4096). The accepted range is the one Windows accepts for the hint. - Linux and macOS do not use it. Go already asks for the maximum and the kernel applies its own limit,
net.core.somaxconn(Linux) orkern.ipc.somaxconn(macOS); raise that sysctl instead. The value is still validated and reported, so the same YAML works on every system, but the reported row is the requested length, not the kernel’s.
There is no environment override. The default 4096 matches the Linux default of net.core.somaxconn.
The shipped YAML states these defaults, so its source is YAML. An omitted setting has source Default. An explicit YAML value equal to the default remains YAML, and an equal-valued override remains Environment. Applied values and sources are captured once; administrative refreshes and later process-environment changes do not reconfigure the listener or rewrite its reported source.
Deployment overrides
Section titled “Deployment overrides”Compose passes the read-timeout override only when supplied; it no longer forces 30s. Base Kubernetes uses the behavior YAML. In Helm, gateway.httpReadTimeoutSeconds defaults to null: the YAML decides. An explicit integer from 5 to 300 retains the existing environment-override behavior. This prevents chart defaults from masking a custom YAML read budget. It does not change shutdown/grace-period settings.
The independent server.healthcheck_url selects the standalone readiness probe and has an empty default. It is not an HTTP listener row or a listener timeout. Its safe startup source is shown separately; see CLI selection and diagnostics.
Inspect the applied settings
Section titled “Inspect the applied settings”With ui and boot_settings_view, the existing administrative configuration API includes three allowlisted rows under infrastructure.settings, the three durations. A request that selects parameter_catalog_version=25 or later (the current console does) also receives a fourth row, server.listen_backlog, whose value is decimal text such as "4096"; every earlier selector, including the default, keeps exactly three rows, so consoles and clients built before the backlog keep reading the snapshot. A raw YAML 0 reports the default value with source YAML. The Settings & sources page shows their applied value, built-in default, source and rollout requirement. That legacy inspector is read-only; it does not write the YAML, change a listener or grant access. Console-sourced rows have paired unavailable value/source in this compatibility projection because its older source schema cannot represent console ownership. Use the dedicated restart-state panel below for their actual values and sources. Existing API permissions and page availability apply. A programmatic gateway factory that did not capture HTTP options reports unavailable applied values/source, rather than claiming defaults were installed in an unknown listener.
The view flag is enabled in the shipped configuration; omission disables it. It can be changed through the existing YAML/API/console flag controls when their management requirements are met. Turning it off omits the new rows and hides the card; HTTP protection still applies. It adds no endpoint/host, environment-variable name or secret to the administrative rows. An Info config_applied record uses the owned actual HTTP observation at boot, including console provenance when applicable, subject to the configured log level. No flag toggle causes a new capture or a listener reload.
The page clears its configuration-derived panels after an authentication/permission refusal and restores them only after a successful authorized refresh. Existing operator API access is preserved; the Settings page does not gain new roles.
Request body limits
Section titled “Request body limits”Every inference route reads the whole request body before it routes it, so the body has a size limit. Base64 images, PDFs and long contexts need more than the built-in limits, which are 1 MiB for Chat Completions and 8 MiB for every other inference route (Messages, Responses, Gemini generateContent, embeddings, images, audio, video, rerank, moderations, decisions, OCR and token counting). You can raise or lower them for the whole gateway and for one alias:
network: max_request_body_mib: 4 # every inference route; 0 or omitted keeps 1 MiB chat / 8 MiB other routesmodels: - id: vision max_request_body_mib: 32 # this alias only, on every route targets: [{provider: openai, model: gpt-4o}]| Parameter | Default | Accepted values | Where it is set | When it applies |
|---|---|---|---|---|
network.max_request_body_mib |
0: 1 MiB chat, 8 MiB other routes |
0, or 1 to 64 |
YAML | At startup; restart each replica |
models[].max_request_body_mib |
omitted: inherits the line above | 1 to 64 |
YAML, model API (PUT /api/v1/admin/models/{id}), console model editor (Request body limit (MiB)) |
Next request after the alias is saved |
When network.max_request_body_mib is set it replaces both built-in limits; an alias value replaces it for that alias, larger or smaller. An alias_of entry uses the value of its canonical model and cannot set its own. For an auto-routed alias, the limit of the auto-route alias applies first and then the limit of the alias it chooses; that second check comes after the routing decision, which may itself call the auto route’s embedding or classifier model, so give the auto-route alias the smallest limit of its candidates to refuse a body before that call.
How a body is checked. Chat Completions, the operations and token counting find the model inside the body, so they read up to the largest limit any alias may have (the route limit or the largest models[].max_request_body_mib), decode the body, and then apply the limit of the named model. Gemini names the alias in the URL and reads no more than that alias’s limit. Either way, a larger body is refused before any guardrail, quota reservation or provider call:
HTTP/1.1 413 Request Entity Too LargeContent-Type: application/json
{"error":{"code":"request_too_large","message":"Request body exceeds the 1 MiB limit of this model"}}A body larger than everything the route reads gets Chat requests are limited to N MiB (chat) or Request exceeds N MiB (other routes) instead, with the same status and code. The Content-Length a client declares does not change the limit.
Memory. A request reserves its declared Content-Length in the request buffer (network.max_buffered_request_mib) while it runs; a chunked body without a length reserves the most the route reads. One alias with a large value therefore makes every chunked request on that route reserve that much, which lowers how many such requests run at once; clients that send Content-Length (the official SDKs do) reserve only what they send. An explicit network.max_buffered_request_mib must be at least the largest limit, or the configuration is refused. With automatic buffer sizing, a body larger than the whole buffer is still admitted alone, holding the entire buffer.
Inspect it. Settings & sources → Infrastructure → Inference HTTP and GET /api/v1/admin/config (infrastructure.inference_http.request_body) show the applied chat and other-route limits with their source (Default or YAML). An alias’s value is in its model entry.
Choosing a value. Providers have their own request limits, usually tens of MiB; raising the gateway limit above the provider’s only moves the refusal to the provider. Keep proxies and ingresses in front of the gateway (their own body-size limits) at or above the value, and keep server.read_timeout long enough for the largest upload.
Upgrade. Nothing changes until you set a value: the defaults stay 1 MiB and 8 MiB. Before rolling back to an older binary, remove both fields, because its strict YAML refuses them.
How the budgets interact
Section titled “How the budgets interact”Header and request-read durations are independent. While headers arrive, the header deadline applies; the remaining body read uses the original request-read budget. For example, read_header_timeout: 60s with read_timeout: 5s is valid and is not silently clamped, but does not promise a 5 s header ceiling. Prefer a header budget no larger than the request-read budget. The keepalive idle budget applies between requests, not to an active answer. These follow the native Go HTTP server semantics.
There is no global write deadline: after input is read, SSE generation follows its operation/stream clocks. WebSocket sessions retain their own limits. Body size limits, authorization, quotas and admission still apply; see routes and capabilities and stream clocks. A read budget is not a minimum upload rate or per-IP throttle.
Chat JSON and optional byte preservation
Section titled “Chat JSON and optional byte preservation”Chat Completions has a 1 MiB body limit by default; see request body limits to change it. A declared body that ends with a transport read error is refused before the provider is called; a complete bounded body is decoded before routing. Authentication, model authorization, guardrails, quota admission and the provider’s own validation still apply.
By default, the gateway encodes the decoded request as before, including the authorized upstream model. An optional operational flag can preserve the original bytes of an eligible same-format Chat request:
features: chat_completions: true preserve_chat_body: truepreserve_chat_body defaults to false and requires chat_completions. With feature_management, use Settings & sources or the existing versioned /api/v1/admin/features/{id} API. It is runtime mutable, audited and synchronized across replicas. Turning it off keeps Chat available and restores ordinary encoding; it grants no model, route or administrative permission.
Original bytes are used only when the model is already encoded exactly as the configured upstream target and the decoded body still matches its original snapshot. The check includes content fingerprints, so a same-length in-place change cannot silently forward old content. A rewrite, consumed cache directive, translation, ambiguous top-level case-folded names, repeated top-level member or invalid UTF-8 falls back to existing encoding. UTF-8 fallback preserves legacy behavior; it does not promise to repair arbitrary nested RawMessage values.
When input guardrails inspect an alias, or budget/TPM flags are enabled, repeated members in any object are refused before dispatch, including case-folded and escaped equivalents. The structural check preserves large valid uninterpreted JSON numbers rather than converting them to float64; quota fields still follow their own strict numeric validation. Outside those protected readers, existing normalization behavior is retained.
Recommendation: keep byte preservation off unless the workload needs eligible original JSON formatting or benefits from lower encoding allocations. Its snapshot/content checks consume additional CPU, especially for larger bodies; profile the complete workload before enabling it. There is no universal throughput improvement or payload-signature guarantee. See the measurement method.
Limits
Section titled “Limits”- Ingresses and proxies in front of the gateway need deadlines consistent with this one.
- Before lowering the deadline, check how long your clients take to send their largest uploads.
- HTTP/2 directly on the listener has not been certified: the profile is HTTP behind a TLS ingress.
See also
Section titled “See also”Save changes for the next startup
Section titled “Save changes for the next startup”The optional boot_settings_management flag defaults to false and requires ui and PostgreSQL. It enables Settings & sources → Restart-required settings and the session-based /api/v1/admin/boot-settings API. It is independent of the legacy boot_settings_view inspector. Global admin can save/revert; global viewer can read. No flag grants permission, and no action restarts the gateway.
The allowlist is exactly the three durations and the listen backlog above. Endpoints, listen addresses, readiness URLs, database connections, secrets, trust, pools and GC are not writable through this API. YAML remains the baseline. A console override replaces all four fields; an empty string selects that duration’s compiled default, and a backlog of 0, an omitted listen_backlog or an explicit 4096 all select 4096, not YAML inheritance. 0s is invalid. The backlog is optional on the wire and the default is never stored: the gateway stores 4096 as an omitted field, and the console leaves the field empty and out of the request unless you choose another value. Overrides saved before the backlog existed therefore keep loading, and replicas that predate it keep reading an override that leaves the backlog at its default.
Set a non-default backlog override only once every replica runs a version with server.listen_backlog. A stored non-default backlog is a fourth field that older gateways refuse: an older replica can then no longer read any control state (its configuration refresh fails), and an older replica that restarts, or a rollback to an older binary, fails to boot with an invalid persisted configuration. Before rolling back, revert the restart policy or save it with the default backlog. A YAML server.listen_backlog has no such effect on other replicas. The same holds when the YAML sets a non-default backlog and no override exists yet: the console’s editor starts from the applied values, so the first save, even one that changes only a timeout, stores that backlog with it.
GET /boot-settings returns listen_backlog in desired, applied and both source objects only when the request selects parameter_catalog_version=25 or later, as the current console does; without it the response keeps the three-duration members. The override is returned as stored, so it names the backlog only when a non-default one was saved; a console from before the backlog then reports the restart state as unavailable instead of dropping the value on its next save.
| Operation | Request | Result |
|---|---|---|
GET /api/v1/admin/boot-settings |
Authorized session | Shared version, process instance ID, raw override, normalized desired/applied values and their per-field sources, pending state and restart_required: true |
| PUT same path | {version, server: {read_timeout, read_header_timeout, idle_timeout, listen_backlog?}} |
Validates the complete candidate, commits with optimistic version and actor/request-ID audit |
| DELETE same path | {version} |
Removes the override; a missing override is 404; restored YAML/default values still need restart when they differ from the running observation |
Read the current version first. For example, the PUT body is {"version": 4, "server": {"read_timeout": "45s", "read_header_timeout": "5s", "idle_timeout": "90s", "listen_backlog": 8192}}; replace 4 with the version you just read and use the console’s same-origin session/CSRF protocol. Omitted durations, unknown, duplicate or case-folded field names, nulls and incorrect types (a backlog must be a JSON integer, not a string or fraction) are refused. A conflict preserves the console draft; reload, review and explicitly rebase before saving.
The precedence for this allowlist is captured nonempty environment > console override > YAML > compiled default. Only read_timeout has the existing environment override; the backlog source is never environment. The raw override stays visible when environment masks it; restart alone cannot remove that mask. Main captures the inputs once and, after a consistent database-backed control snapshot, chooses one owned startup observation before listening. Runtime refresh never changes the installed server fields.
desired means the next startup using this process’s YAML and captured environment; applied means this process’s actual immutable startup observation. Sources are default, yaml, console or environment. Only the stored override is shared: replica YAML/environment and applied state can differ. Pending compares normalized values and source ownership, not the global configuration version. Adopting an equal-valued console override can therefore require a restart. Unknown factory captures return null for desired/applied values, sources and pending state; writes fail with 503 rather than inventing a listener configuration.
Turning management off leaves the dormant override stored and makes the next startup use its baseline; it does not change the running listener. Re-enabling can adopt the saved override on a later restart. A persisted management flag is discovered at boot only when an existing storage-backed YAML profile already opens PostgreSQL, such as feature_management. A DSN alone with every storage-backed feature disabled does not add an always-connect dependency.
Migration100 is additive. Roll out supporting binaries everywhere before enabling management, back up first and follow operations. Invalid persisted startup policy fails before listen with a safe structured error; a later read/validation failure preserves the last valid desired and applied observation. Configuration revert does not undo schema migrations. No process restart, cluster rollout, infrastructure provisioning or automatic data migration is performed by this feature.