Skip to content
Latest (currently 2026.10.2) has the newest features, bug fixes, and CVE patches of Solo Enterprise for agentgateway.

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Anthropic

Page as Markdown

Configuration and setup for Anthropic Claude provider.

Configure Anthropic (Claude) as an LLM provider in agentgateway.

Note

Anthropic excludes cached tokens from the input count that it reports. The CEL field llm.inputTokens adds them back, so telemetry, metrics, and token-based limits count a cache-heavy request higher than the number that Anthropic reports. To read the Anthropic number itself, use llm.providerInputTokens. For more information, see Token usage fields.

Client response bodies use the usage convention for the API format that the client called. A /v1/messages response uses Anthropic usage fields. In that response, usage.input_tokens excludes prompt-cache tokens and cache counts appear separately. A /v1/chat/completions response uses OpenAI usage fields, and usage.prompt_tokens includes prompt-cache tokens.

When Anthropic reports usage.iterations, the /v1/messages response keeps that array. Telemetry, cost calculations, and converted Chat Completions responses use the sum of the iteration entries.

For Anthropic Messages and token-count requests, a client anthropic-version header is forwarded. If the client sends no version header, the request uses the default 2023-06-01 version.

To add prompt-cache markers automatically, set backend.ai.promptCaching in an EnterpriseAgentgatewayPolicy resource. The setting also works for Claude models on Vertex AI. If a request already has cache_control markers, the policy adds none. The minTokens value applies only to system prompt caching. For the fields and their defaults, see Prompt caching on Bedrock.

Before you begin

Install the Solo Enterprise for agentgateway control plane by following the quick start guide.

Set up access to Anthropic

  1. Get an API key to access the Anthropic API.

  2. Save the API key in an environment variable.

    export ANTHROPIC_API_KEY=<insert your API key>
  3. Create a Kubernetes secret to store your Anthropic API key.

    kubectl apply -f- <<EOF
    apiVersion: v1
    kind: Secret
    metadata:
      name: anthropic-secret
      namespace: agentgateway-system
    type: Opaque
    stringData:
      Authorization: $ANTHROPIC_API_KEY
    EOF
  4. Create an EnterpriseAgentgatewayBackend resource to configure your LLM provider that references the Anthropic API key secret.

    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: anthropic
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          anthropic:
            model: "claude-opus-4-6"
      policies:
        auth:
          secretRef:
            name: anthropic-secret
    EOF

    Review the following table to understand this configuration. For more information, see the API reference.

    SettingDescription
    ai.provider.anthropicDefine the LLM provider that you want to use. The example uses Anthropic.
    anthropic.modelThe model to use to generate responses. In this example, you use the claude-opus-4-6 model.
    policies.authProvide the credentials to use to access the Anthropic API. The example refers to the secret that you previously created. The token is automatically sent in the x-api-key header.
  5. Create an HTTPRoute resource that routes incoming traffic to the EnterpriseAgentgatewayBackend. The following example sets up a route on the /anthropic path. Note that Solo Enterprise for agentgateway automatically rewrites the endpoint to the Anthropic /v1/messages endpoint.

    kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: anthropic
      namespace: agentgateway-system
    spec:
      parentRefs:
        - name: agentgateway-proxy
          namespace: agentgateway-system
      rules:
      - backendRefs:
        - name: anthropic
          namespace: agentgateway-system
          group: enterpriseagentgateway.solo.io
          kind: EnterpriseAgentgatewayBackend
    EOF
    kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: anthropic
      namespace: agentgateway-system
    spec:
      parentRefs:
        - name: agentgateway-proxy
          namespace: agentgateway-system
      rules:
      - matches:
        - path:
            type: PathPrefix
            value: /v1/chat/completions
        backendRefs:
        - name: anthropic
          namespace: agentgateway-system
          group: enterpriseagentgateway.solo.io
          kind: EnterpriseAgentgatewayBackend
    EOF
    kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: anthropic
      namespace: agentgateway-system
    spec:
      parentRefs:
        - name: agentgateway-proxy
          namespace: agentgateway-system
      rules:
      - matches:
        - path:
            type: PathPrefix
            value: /anthropic
        backendRefs:
        - name: anthropic
          namespace: agentgateway-system
          group: enterpriseagentgateway.solo.io
          kind: EnterpriseAgentgatewayBackend
    EOF
  6. Send a request to the LLM provider API along the route that you previously created. Verify that the request succeeds and that you get back a response from the API.

    Cloud Provider LoadBalancer:

    curl "$INGRESS_GW_ADDRESS/v1/messages" -H content-type:application/json  -d '{
       "model": "",
       "messages": [
         {
           "role": "user",
           "content": "Explain how AI works in simple terms."
         }
       ]
     }' | jq

    Localhost:

    curl "localhost:8080/v1/messages" -H content-type:application/json  -d '{
       "model": "",
       "messages": [
         {
           "role": "user",
           "content": "Explain how AI works in simple terms."
         }
       ]
     }' | jq

    Cloud Provider LoadBalancer:

    curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json  -d '{
       "model": "",
       "messages": [
         {
           "role": "user",
           "content": "Explain how AI works in simple terms."
         }
       ]
     }' | jq

    Localhost:

    curl "localhost:8080/v1/chat/completions" -H content-type:application/json  -d '{
       "model": "",
       "messages": [
         {
           "role": "user",
           "content": "Explain how AI works in simple terms."
         }
       ]
     }' | jq

    Cloud Provider LoadBalancer:

    curl "$INGRESS_GW_ADDRESS/anthropic" -H content-type:application/json  -d '{
       "model": "",
       "messages": [
         {
           "role": "user",
           "content": "Explain how AI works in simple terms."
         }
       ]
     }' | jq

    Localhost:

    curl "localhost:8080/anthropic" -H content-type:application/json  -d '{
       "model": "",
       "messages": [
         {
           "role": "user",
           "content": "Explain how AI works in simple terms."
         }
       ]
     }' | jq

    Example output:

    {
      "model": "claude-opus-4-6",
      "usage": {
        "prompt_tokens": 16,
        "completion_tokens": 318,
        "total_tokens": 334
      },
      "choices": [
        {
          "message": {
            "content": "Artificial Intelligence (AI) is a field of computer science that focuses on creating machines that can perform tasks that typically require human intelligence, such as visual perception, speech recognition, decision-making, and language translation. Here's a simple explanation of how AI works:\n\n1. Data input: AI systems require data to learn and make decisions. This data can be in the form of images, text, numbers, or any other format.\n\n2. Training: The AI system is trained using this data. During training, the system learns to recognize patterns, relationships, and make predictions based on the input data.\n\n3. Algorithms: AI uses various algorithms, which are sets of instructions or rules, to process and analyze the data. These algorithms can be simple or complex, depending on the task at hand.\n\n4. Machine Learning: A subset of AI, machine learning, enables the system to automatically learn and improve from experience without being explicitly programmed. As the AI system is exposed to more data, it can refine its algorithms and become more accurate over time.\n\n5. Output: Once the AI system has processed the data, it generates an output. This output can be a prediction, a decision, or an action, depending on the purpose of the AI system.\n\nAI can be categorized into narrow (weak) AI and general (strong) AI. Narrow AI is designed to perform a specific task, such as playing chess or recognizing speech, while general AI aims to have human-like intelligence that can perform any intellectual task.",
            "role": "assistant"
          },
          "index": 0,
          "finish_reason": "stop"
        }
      ],
      "id": "msg_01PbaJfDHnjEBG4BueJNR2ff",
      "created": 1764627002,
      "object": "chat.completion"
    }

Send inline files through Chat Completions

When a client sends a /v1/chat/completions request to Anthropic through agentgateway, an inline file content part becomes an Anthropic Messages document block. Set file.file_data to a base64 data: URI, such as data:application/pdf;base64,<base64>. The document title comes from file.filename. The conversion rejects a file_id, raw base64 string, remote URL, or file part with no content. Those forms have no inline content to send to Anthropic.

Extended thinking and reasoning

Extended thinking and reasoning lets Claude reason through complex problems before generating a response. You can opt in to extended thinking and reasoning by adding specific parameters to your request.

Note

Extended thinking and reasoning requires a Claude model that supports these, such as claude-opus-4-6.

To opt in to extended thinking, include the thinking.type field in your request. You can also set the output_config.effort field to control how much reasoning the model applies.

The following values are supported:

thinking field

type valueAdditional fieldsBehavior
adaptiveoutput_config.effortThe model decides whether to think and how much. Requires output_config.effort to be set.
enabledbudget_tokens: <number>Explicitly enables thinking with a fixed token budget. Works standalone without output_config.
disablednoneExplicitly disables thinking.

output_config field

output_config has two independent sub-fields. You can use either or both.

Sub-fieldDescription
effortControls the reasoning effort level. Accepted values: low, medium, high, max.
formatConstrains the response to a JSON schema. Set type to json_schema and provide a schema object. For more information, see Structured outputs.

The following example request uses adaptive extended thinking. Note that this setting requires the output_config.effort field to be set too.

Cloud Provider LoadBalancer:

curl "$INGRESS_GW_ADDRESS/v1/messages" -H content-type:application/json -d '{
  "model": "",
  "max_tokens": 1024,
  "thinking": {
    "type": "adaptive"
  },
  "output_config": {
    "effort": "high"
  },
  "messages": [
    {
      "role": "user",
      "content": "Explain the trade-offs between consistency and availability in distributed systems."
    }
  ]
}' | jq

Localhost:

curl "localhost:8080/v1/messages" -H content-type:application/json -d '{
  "model": "",
  "max_tokens": 1024,
  "thinking": {
    "type": "adaptive"
  },
  "output_config": {
    "effort": "high"
  },
  "messages": [
    {
      "role": "user",
      "content": "Explain the trade-offs between consistency and availability in distributed systems."
    }
  ]
}' | jq

Example output:

{
  "id": "msg_01HVEzWf4NJrsKyVeEUDnHNW",
  "type": "message",
  "role": "assistant",
  "model": "claude-opus-4-6",
  "content": [
    {
      "type": "thinking",
      "thinking": "Let me think through the trade-offs between consistency and availability..."
    },
    {
      "type": "text",
      "text": "# Consistency vs. Availability in Distributed Systems\n\n..."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 21,
    "output_tokens": 1024
  }
}

Use the reasoning_effort field in your request to enable extended thinking. The value that you set is automatically mapped to a specific thinking budget as shown in the following table.

reasoning_effort valueThinking budget
minimal or low1,024 tokens
medium2,048 tokens
high4,096 tokens
xhigh8,192 tokens in agentgateway 1.4 and later. 4,096 tokens in earlier versions, including 2.2.x.
max16,384 tokens. Supported in agentgateway 1.4 and later.

Note that the max_tokens value must be greater than the tokens in the thinking budget for the request to succeed.

Cloud Provider LoadBalancer:

curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json -d '{
  "model": "",
  "max_tokens": 6000,
  "reasoning_effort": "high",
  "messages": [
    {
      "role": "user",
      "content": "Explain the trade-offs between consistency and availability in distributed systems."
    }
  ]
}' | jq

Localhost:

curl "localhost:8080/v1/chat/completions" -H content-type:application/json -d '{
  "model": "",
  "max_tokens": 6000,
  "reasoning_effort": "high",
  "messages": [
    {
      "role": "user",
      "content": "Explain the trade-offs between consistency and availability in distributed systems."
    }
  ]
}' | jq

Example output:

{
  "model": "claude-opus-4-6",
  "usage": {
    "prompt_tokens": 50,
    "completion_tokens": 2549,
    "total_tokens": 2599,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0
  },
  "choices": [
    {
      "message": {
        "content": "# Consistency vs. Availability in Distributed ..."
      },
      "index": 0,
      "finish_reason": "stop"
    }
  ],
  "id": "msg_01CVnXAQYeWkUjeaDceBRk3e",
  "created": 1773251049,
  "object": "chat.completion"
}

Structured outputs

Structured outputs constrain the model to respond with a specific JSON schema. You must provide the schema definition in your request.

Provide the JSON schema definition in the output_config.format field.

Cloud Provider LoadBalancer:

curl "$INGRESS_GW_ADDRESS/v1/messages" -H content-type:application/json -d '{
  "model": "",
  "max_tokens": 256,
  "output_config": {
    "format": {
      "type": "json_schema",
      "schema": {
        "type": "object",
        "properties": {
          "answer": { "type": "string" },
          "confidence": { "type": "number" }
        },
        "required": ["answer", "confidence"],
        "additionalProperties": false
      }
    }
  },
  "messages": [
    {
      "role": "user",
      "content": "Is the sky blue? Respond with your answer and a confidence score between 0 and 1."
    }
  ]
}' | jq

Localhost:

curl "localhost:8080/v1/messages" -H content-type:application/json -d '{
  "model": "",
  "max_tokens": 256,
  "output_config": {
    "format": {
      "type": "json_schema",
      "schema": {
        "type": "object",
        "properties": {
          "answer": { "type": "string" },
          "confidence": { "type": "number" }
        },
        "required": ["answer", "confidence"],
        "additionalProperties": false
      }
    }
  },
  "messages": [
    {
      "role": "user",
      "content": "Is the sky blue? Respond with your answer and a confidence score between 0 and 1."
    }
  ]
}' | jq

Example output:

{
  "id": "msg_01PsCxtLN1vftAKZgvWXhCan",
  "type": "message",
  "role": "assistant",
  "model": "claude-opus-4-6",
  "content": [
    {
      "type": "text",
      "text": "{\"answer\":\"Yes, the sky is blue during clear daytime conditions.\",\"confidence\":0.98}"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 29,
    "output_tokens": 28
  }
}

Provide the schema definition in the response_format field.

Cloud Provider LoadBalancer:

curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json -d '{
  "model": "",
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "answer_schema",
      "schema": {
        "type": "object",
        "properties": {
          "answer": { "type": "string" },
          "confidence": { "type": "number" }
        },
        "required": ["answer", "confidence"],
        "additionalProperties": false
      }
    }
  },
  "messages": [
    {
      "role": "user",
      "content": "Is the sky blue? Respond with your answer and a confidence score between 0 and 1."
    }
  ]
}' | jq

Localhost:

curl "localhost:8080/v1/chat/completions" -H content-type:application/json -d '{
  "model": "",
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "answer_schema",
      "schema": {
        "type": "object",
        "properties": {
          "answer": { "type": "string" },
          "confidence": { "type": "number" }
        },
        "required": ["answer", "confidence"],
        "additionalProperties": false
      }
    }
  },
  "messages": [
    {
      "role": "user",
      "content": "Is the sky blue? Respond with your answer and a confidence score between 0 and 1."
    }
  ]
}' | jq

Example output:

{
  "model": "claude-opus-4-6",
  "usage": {
    "prompt_tokens": 192,
    "completion_tokens": 68,
    "total_tokens": 260,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0
  },
  "choices": [
    {
      "message": {
        "content": "{\"answer\":\"Yes, the sky is blue...",
        "role": "assistant"
      },
      "index": 0,
      "finish_reason": "stop"
    }
  ],
  "id": "msg_01BLohqXbvfZHQnnXxmviCcg",
  "created": 1773251560,
  "object": "chat.completion"
}

Use Claude Platform on AWS

Claude Platform on AWS hosts Anthropic’s native Messages API on AWS infrastructure at aws-external-anthropic.{region}.api.aws. Because the API is the same Anthropic Messages API, you point the anthropic provider at the AWS endpoint and choose either API-key or AWS SigV4 authentication.

  1. Create a Kubernetes secret that contains your Anthropic-on-AWS API key.

    export ANTHROPIC_AWS_API_KEY=<insert your API key>
    kubectl apply -f- <<EOF
    apiVersion: v1
    kind: Secret
    metadata:
      name: anthropic-aws-secret
      namespace: agentgateway-system
    type: Opaque
    stringData:
      Authorization: $ANTHROPIC_AWS_API_KEY
    EOF
  2. Create a EnterpriseAgentgatewayBackend that points the anthropic provider at the Claude Platform endpoint and references the API key secret.

    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: anthropic-aws
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          anthropic: {}
          host: aws-external-anthropic.us-west-2.api.aws
          port: 443
          pathPrefix: /v1
      policies:
        auth:
          secretRef:
            name: anthropic-aws-secret
    EOF
    SettingDescription
    provider.anthropicMarks the provider as Anthropic. No model override is required, so the field is left empty.
    provider.hostThe Claude Platform endpoint hostname. Use the form aws-external-anthropic.{region}.api.aws.
    provider.portThe HTTPS port for Claude Platform, set to 443.
    provider.pathPrefixThe Anthropic API path prefix on Claude Platform, set to /v1.
    policies.auth.secretRefReferences the secret that holds the API key. The token is automatically sent in the x-api-key header.

Warning

These steps store the gateway’s credentials in AGW_-prefixed environment variables, as opposed to the standard AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN variables that the aws CLI and the AWS SDKs read. This way, when you export the variables, you do not replace your own personal user identity for the rest of the shell session, which could lead to unexpected auth errors. To use the standard names anyway, set them in a subshell, or store the gateway’s credentials in a named AWS profile and select that profile with AWS_PROFILE for the agentgateway process only.

  1. Make sure the agentgateway proxy pod has access to AWS credentials, for example through IRSA or a Kubernetes secret with accessKey, secretKey, and optional sessionToken. For the secret-based approach, save the credentials as environment variables.

    export AGW_AWS_ACCESS_KEY_ID="<aws-access-key-id>"
    export AGW_AWS_SECRET_ACCESS_KEY="<aws-secret-access-key>"
    export AGW_AWS_SESSION_TOKEN="<aws-session-token>"

    Then, create the secret.

    kubectl create secret generic anthropic-aws-creds \
      -n agentgateway-system \
      --from-literal=accessKey="$AGW_AWS_ACCESS_KEY_ID" \
      --from-literal=secretKey="$AGW_AWS_SECRET_ACCESS_KEY" \
      --from-literal=sessionToken="$AGW_AWS_SESSION_TOKEN" \
      --type=Opaque \
      --dry-run=client -o yaml | kubectl apply -f -
  2. Create a EnterpriseAgentgatewayBackend that points the anthropic provider at the Claude Platform endpoint and uses AWS SigV4 authentication with the aws-external-anthropic service name.

    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: anthropic-aws
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          anthropic: {}
          host: aws-external-anthropic.us-west-2.api.aws
          port: 443
          pathPrefix: /v1
      policies:
        auth:
          aws:
            serviceName: aws-external-anthropic
            secretRef:
              name: anthropic-aws-creds
    EOF
    SettingDescription
    provider.anthropicMarks the provider as Anthropic. No model override is required, so the field is left empty.
    provider.hostThe Claude Platform endpoint hostname. Use the form aws-external-anthropic.{region}.api.aws.
    provider.portThe HTTPS port for Claude Platform, set to 443.
    provider.pathPrefixThe Anthropic API path prefix on Claude Platform, set to /v1.
    policies.auth.aws.serviceNameThe SigV4 service name. Claude Platform requires aws-external-anthropic.
    policies.auth.aws.secretRefReferences the secret with AWS credentials. To use implicit credentials from the workload environment (for example IRSA), omit secretRef.
  1. Create an HTTPRoute that routes traffic to the EnterpriseAgentgatewayBackend. The example also injects the anthropic-workspace-id header that Claude Platform requires. Replace wrkspc_XXXXX with your Anthropic workspace ID.

    kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: anthropic-aws
      namespace: agentgateway-system
    spec:
      parentRefs:
        - name: agentgateway-proxy
          namespace: agentgateway-system
      rules:
      - filters:
        - type: RequestHeaderModifier
          requestHeaderModifier:
            set:
            - name: anthropic-workspace-id
              value: wrkspc_XXXXX
        backendRefs:
        - name: anthropic-aws
          namespace: agentgateway-system
          group: enterpriseagentgateway.solo.io
          kind: EnterpriseAgentgatewayBackend
    EOF

Use Claude on Azure AI Foundry

To use Claude models through Azure AI Foundry, configure the azure provider with resourceType: Foundry and a claude-* model name. Agentgateway automatically routes requests to the Anthropic-native endpoint and injects the required headers — no additional configuration is needed.

For setup instructions, see Use Claude models on Azure AI Foundry.

Connect to Claude Code

To route Claude Code CLI traffic through agentgateway, see the Claude Code integration guide.

Next steps