Headers let you steer one request without changing your organization’s configuration: pick a routing config, add guardrails, skip the cache, or keep bodies out of the logs. Response headers tell you how the gateway handled the request.

How it works

The gateway reads its own headers, acts on them, and removes the control headers (X-ManyLayers-Guardrails, X-ManyLayers-Store-Logs, X-ManyLayers-Cache-Control, X-ManyLayers-Cache-Type, X-ManyLayers-Cache-Ttl, X-ManyLayers-Cache-Namespace, X-ManyLayers-Cache-Threshold, X-ManyLayers-Credential) and the metadata header (X-ManyLayers-Metadata) before forwarding the request, so providers never see them. An unrecognized value in a control header is refused with 400 rather than ignored.

Sending metadata

Because the gateway is OpenAI-compatible, you send X-ManyLayers-Metadata with the OpenAI SDK by setting it as a default header on the client — no custom transport needed. The metadata is recorded on the request trace and read by conditional routing, Auto Routing and guardrail rules. Its most common use is per-end-user tracking: tag every call with the identity of your own user, and the gateway attributes usage, enforces per-user budgets and rate limits, and lets an administrator block a user who overspends — all on one shared key. user_id is the identity; name and email are optional and only make the user easier to recognise (and block) in Gateway → Access → End Users. See End Users for the full SDK setup and End-User Usage API for reading usage back.
Send the identity from your trusted backend, where you already know which of your users is calling — never from an untrusted browser, since a client could change it to escape its own budget or impersonate another user. To call from a client, put your own backend in front to set the header.

Request headers

string
required
Bearer <token>. An API key (ml-...), personal access token (ml_pat_...), virtual account token (ml_vat_...) or an OIDC JWT. When Authorization is absent the gateway falls back to x-api-key (what the Anthropic SDK sends); Authorization wins when both are present. See Authentication.
string
Id or name of a routing config to apply to this request. Overrides the team’s default config. Unknown names return 400 unknown_config; a config that doesn’t serve the endpoint you called is refused. Ignored when the model is itself a virtual model, which brings its own config.
JSON object
Flat key/value pairs, for example {"tenant":"acme","env":"prod"}. Recorded on the request trace and matched by conditional routing targets, Auto Routing conditions and guardrail rules. At most 8 KB and 64 keys; values over 512 bytes, objects and arrays are dropped. A malformed header counts as no metadata. The key that names an end user is end_users.metadata_key (default user_id).
JSON object
Adds guardrails for this request: {"input_guardrails": ["pii-strict"], "output_guardrails": ["toxicity"]}. It can only add to what your organization’s rules apply, never remove. Up to 32 names and 8 KB. Requires the gateway.guardrails.read permission; unknown names return 400 unknown_guardrail.
string
no-cache skips the cache lookup; no-store skips writing the answer to the cache. Combine with a comma. Cannot make a request cacheable that your team’s settings exclude.
string
exact uses only the exact-match cache; semantic uses only the similarity cache. Without it both layers are used, exact first. semantic on a gateway with no semantic cache configured returns 400 semantic_cache_unavailable instead of running the request uncached. A caller holding gateway.workspaces.manage (or the operator) can also use this header to opt a single request into the cache when its team and workspace have not switched it on.
integer
Seconds to keep this request’s answer in the cache, from 1 to 604800 (one week), whatever lifetime the cache is configured with. Anything else returns 400. Cannot make a request cacheable that your team’s settings exclude.
string
Partitions the cache within your team and workspace: entries written under one namespace are never served to another. 1 to 128 characters of letters, digits and . _ : -; anything else returns 400 invalid_header.
number
Minimum similarity for a semantic-cache hit on this request, above 0 and at most 1. Anything else returns 400 invalid_header.
string
false keeps this request’s prompt and response bodies out of the audit log. true is accepted and changes nothing: it can’t turn capture on where a logging rule turns it off.
string
Sticky-session key. Sticky-session routing and canary/loadbalance configs send requests with the same key to the same target; if the header is absent they use the body’s user field. Auto Routing reads only this header to pin a conversation’s tier.
string
Model for /v1/files and /v1/fine_tuning/jobs calls whose body names no model. You can use ?model= instead. POST /v1/fine_tuning/jobs takes the model in its JSON body, which wins over this header. Missing returns 400 missing_model.
string
Console sessions only. Id of one of your own personal access tokens; the request is attributed to that token. Sending it with an API key returns 400 credential_header_not_allowed.
string
Free-form label for the calling surface (for example playground). Lowercased, limited to letters, digits, _ and -, 32 characters. Used in logs and traces only; it grants nothing.
string
Correlation id. If you send one, the gateway uses it as is in logs and audit records and echoes it back; otherwise it generates a UUID.
string
W3C trace context (tracestate is read too). Honoured only when the deployment sets telemetry.trace_propagation: true; then the gateway continues your trace. Otherwise the header is ignored and every request starts a new trace. The gateway does not rewrite it: it is passed through to the provider unchanged.

Response headers

string
The request’s correlation id, on every response.
string
Id of the audit record for this request. Open it in the console’s trace view. Returned on the text-generation endpoints (/v1/chat/completions, /v1/completions, /v1/embeddings, /v1/messages, /v1/responses).
string
W3C trace id of the distributed trace, present when a tracing destination is configured. Use it to search your own tracing backend.
string
hit, semantic, miss, bypass (you sent no-cache) or disabled (the request isn’t cache-eligible).
string
Sent with X-ManyLayers-Cache: disabled, and says why: not_enabled (neither the request’s team nor its workspace has switched the cache on; turn it on in Gateway → Settings → Cache config), not_deterministic (the request’s temperature isn’t 0 and the model isn’t marked cacheable), no_backend (the gateway has no cache configured) or embeddings (embedding requests are never cached).
string
On a cache hit, the id of the request that originally produced the cached answer.
number
On a semantic hit, the similarity score, to four decimals.
string
Name of the routing config that handled the request.
string
The model that served the response after routing and failover.
integer
Number of retries spent on the serving target.
string
Strategy of the config that routed the request, for example fallback or complexity.
string
Comma-separated order in which targets would be tried.
string
Targets passed over without being called, as model=reason pairs. Reasons: metadata_mismatch, not_allowed, model_restriction, unresolvable, ambiguous, budget_exceeded, rate_limited, unsupported_feature (the target’s provider cannot honour the tools, forced tool_choice or JSON output the request needs).
string
Auto Routing only. The tier the request was classified as: simple, medium or complex.
string
Auto Routing only. How the tier was chosen, for example heuristic or pinned. A -fallback suffix means the LLM classifier failed and the heuristic decided.
string
Auto Routing only. The tier of the target that actually answered, which differs from the classified tier after a failover.
string
buffered-streaming when a streamed response was held until output guardrails finished.
string
On a policy refusal, the level whose limit was hit: organization, workspace, team, service_account, user, api_key or end_user. Sent with Retry-After (seconds) when waiting will help. The gateway sends no X-RateLimit-* headers.
number
Estimated cost in USD for the image and audio endpoints when the model has a price configured.

Common configurations

Read X-ManyLayers-Routing-Model-Order, X-ManyLayers-Skipped-Targets, X-ManyLayers-Target and X-ManyLayers-Retries together. Then open the trace with X-ManyLayers-Trace-Id.
The audit row is still written (who, which model, tokens, cost), but without bodies, and the answer is neither read from nor written to the cache.
A routing config with strict_openai_compliance: true stops the gateway from adding the routing headers (X-ManyLayers-Config, -Target, -Retries, -Routing-Strategy, -Routing-Model-Order, -Skipped-Targets, -Complexity-*, -Served-Tier) and strips gateway extension fields from non-streaming JSON bodies. X-ManyLayers-Cache is always kept.
Cross-origin browser access is off by default. A deployment enables it only for the console origin it names in PUBLIC_WORKSPACE_URL; for that origin the CORS policy exposes X-Request-Id and the X-ManyLayers-* response headers above, except X-ManyLayers-Otel-Trace-Id and X-ManyLayers-Limit. Browser apps on other origins should call the gateway from their backend.

Next steps

Making Requests

SDK setup, streaming and error handling.

Routing

Configs, strategies and sticky sessions.

Guardrails

Rules that per-request guardrails add to.

Caching

What makes a request cache-eligible.