Connect Anthropic
This guide will help you configure Envoy AI Gateway to work with Anthropic's models.
Prerequisites
Before you begin, you'll need:
- An Anthropic API key from Anthropic's console
- Basic setup completed from the Basic Usage guide
- Basic configuration removed as described in the Advanced Configuration overview
Configuration Steps
Ensure you have followed the steps in Connect Providers
1. Download configuration template
curl -O https://raw.githubusercontent.com/envoyproxy/ai-gateway/main/examples/basic/anthropic.yaml
2. Configure Anthropic Credentials
Edit the anthropic.yaml file to replace the Anthropic placeholder value:
- Find the section containing
ANTHROPIC_API_KEY - Replace it with your actual Anthropic API key
Make sure to keep your API key secure and never commit it to version control. The key will be stored in a Kubernetes secret.
3. Apply Configuration
Apply the updated configuration and wait for the Gateway pod to be ready. If you already have a Gateway running, then the secret credential update will be picked up automatically in a few seconds.
kubectl apply -f anthropic.yaml
kubectl wait pods --timeout=2m \
-l gateway.envoyproxy.io/owning-gateway-name=envoy-ai-gateway-basic \
-n envoy-gateway-system \
--for=condition=Ready
4. Test the Configuration
You should have set $GATEWAY_URL as part of the basic setup before connecting to providers.
See the Basic Usage page for instructions.
Test Chat Completions
curl -H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"messages": [
{
"role": "user",
"content": "Hi."
}
]
}' \
$GATEWAY_URL/v1/chat/completions
Troubleshooting
If you encounter issues:
-
Verify your API key is correct and active
-
Check pod status:
kubectl get pods -n envoy-gateway-system -
View controller logs:
kubectl logs -n envoy-ai-gateway-system deployment/ai-gateway-controller -
View External Processor Logs
kubectl logs -n envoy-gateway-system -l gateway.envoyproxy.io/owning-gateway-name=envoy-ai-gateway-basic -c ai-gateway-extproc -
Common errors:
- 401: Invalid API key
- 429: Rate limit exceeded
- 503: Anthropic service unavailable
Configuring More Models
To use more models, add more AIGatewayRouteRules to the anthropic.yaml file with the model name in the value field.
For example, let's add claude-haiku-3-5 as a chat completion model:
apiVersion: aigateway.envoyproxy.io/v1alpha1
kind: AIGatewayRoute
metadata:
name: envoy-ai-gateway-basic-anthropic
namespace: default
spec:
parentRefs:
- name: envoy-ai-gateway-basic
kind: Gateway
group: gateway.networking.k8s.io
rules:
- matches:
- headers:
- type: Exact
name: x-ai-eg-model
value: claude-sonnet-4-5
- matches:
- headers:
- type: Exact
name: x-ai-eg-model
value: claude-haiku-3-5
backendRefs:
- name: envoy-ai-gateway-basic-anthropic
Next Steps
After configuring Anthropic:
- Connect OpenAI to add another provider
- Connect AWS Bedrock to add another provider