Transformations

Attach to:

Route

Agentgateway uses transformation Transformation The process of modifying HTTP requests or responses as they pass through agentgateway. Transformations can change headers, body content, and other request/response attributes. templates that are written in Common Expression Language (CEL) CEL (Common Expression Language) A simple expression language used throughout agentgateway to enable flexible configuration. CEL expressions can access request context, JWT claims, and other variables to make dynamic decisions. . CEL is a fast, portable, and safely executable language that goes beyond declarative configurations. CEL lets you develop more complex expressions in a readable, developer-friendly syntax.

To learn more about how to use CEL, refer to the following resources:

ℹ️
Try out CEL expressions in the built-in CEL playground in the agentgateway admin UI before using them in your configuration.

Header transformation

You can add, set, or remove request and response headers with agentgateway’s transformation policies.

ℹ️
To provide a specific string value, add your string in single quotes ' followed by double quotes ". This way, the string is interpreted as a string value. If you provide the value without quotes or with double quotes only, it is interpreted as a CEL expression.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
binds:
- port: 3000
  listeners:
  - routes:
    - backends:
      - ai:
         name: openai
         provider:
           openAI:
             # Optional; overrides the model in requests
             model: gpt-3.5-turbo
      policies:
        backendAuth:
          key: "$OPEN_AI_APIKEY"
        cors:
          allowOrigins:
            - "*"
          allowHeaders:
            - "*"
        transformations:
          request:
            add:
              x-gateway: '"agentgateway"'
          response:
            add:
              x-served-by: '"agentgateway"'
            remove:
            - server
            - x-content-type-options
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
binds:
- port: 3000
  listeners:
  - gatewayName: my-gateway
    routes:
    - backends:
      - ai:
         name: openai
         provider:
           openAI:
             # Optional; overrides the model in requests
             model: gpt-3.5-turbo
      policies:
        backendAuth:
          key: "$OPEN_AI_APIKEY"
        cors:
          allowOrigins:
            - "*"
          allowHeaders:
            - "*"   
gatewayPolicies:
  - name: global-transformations
    target:
      gateway: my-gateway
    policy:
      transformations:
        request:
          add:
            x-gateway: '"agentgateway"'
        response:
          add:
            x-served-by: '"agentgateway"'

Body transformation

You can provide a custom body for a request or response.

ℹ️
To provide a specific string value, add your string in single quotes ' followed by double quotes ". This way, the string is interpreted as a string value. If you provide the value without quotes or with double quotes only, it is interpreted as a CEL expression.
transformations:
  request:
    body:
      '"This is a custom request body."'
  response:
    body:
      '"This is a custom response body."'
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.