- AI Gateway
- 1.2.0
Transform requests and responses¶
Sometimes the call a client sends is not quite the call the upstream should receive. A provider expects a header the client doesn't set, an internal header shouldn't leak to a third-party model, or a request should be answered at the gateway instead of going upstream at all.
These policies apply to any API the gateway fronts, not only to LLM and MCP traffic.
Where transformation policies run¶
You attach them in the operationPolicies block of an LlmProxy, an LlmProvider, or an Mcp resource. Each policy declares the phase it runs in: a header set on the request reaches the upstream, while one set on the response reaches the client.
Position in the chain decides what a policy sees. A header removed before a logging policy runs never appears in the log; removed after, it does. For how the gateway sequences a chain, see Guardrail execution order.
Transformation policies¶
These policies are documented in the Policy Hub, the versioned reference for every API Platform policy. For policy categories and how policies chain, see the Policy Hub overview.
| Policy | What it does |
|---|---|
| Set Headers | Adds or overwrites headers on requests or responses |
| Remove Headers | Strips specified headers from requests or responses |
| Respond | Returns an immediate response without forwarding to the upstream backend |
The Policy Hub's Transformation category covers further options that apply to any API: rewriting a request's path, query parameters, or method; overriding the Host header sent upstream; routing to a named upstream at runtime; converting payloads between JSON and XML; and calling an external HTTP service during the request or response phase. See the Policy Hub overview for the full category.
To translate an OpenAI-shaped request into another provider's API shape, which is a transformation with its own dedicated policies, see Multi-provider routing.
Related topics¶
- Prompt management — reshape the prompt itself rather than the envelope around it.
- Analytics header filter — control which headers reach an analytics backend, rather than which reach the upstream.
- Multi-provider routing — the provider-shape transformers and how they pair with routing.