ai_gateway_model_providers:
- ref: coding-agents-anthropic-provider
name: coding-agents-anthropic-provider
type: anthropic
config:
auth:
type: basic
headers:
- name: x-api-key
value: !secret {source: !env 'ANTHROPIC_TOKEN'}
ai_gateway_models:
- ref: coding-agents-anthropic
name: coding-agents-anthropic
type: model
formats:
- type: passthrough
capabilities:
- generate
access:
auth_strategies:
- coding-agents-key-auth
config:
max_request_body_size: 16777216
response_streaming: allow
logging:
payloads: true
route:
paths:
- /coding-agents-anthropic
protocols:
- http
- https
methods:
- POST
- OPTIONS
strip_path: true
targets:
- name: anthropic-api
provider: coding-agents-anthropic-provider
config:
version: !env 'ANTHROPIC_VERSION'
type: anthropic
upstream_url: https://api.anthropic.com/
config.auth.headers (AI Model Provider): The header Kong adds to every upstream request. Anthropic authenticates API keys through x-api-key, so the AI Model Provider sets that header to the organization’s key.
formats: [{type: passthrough}]: Forwards bodies without translation or validation. The passthrough format can’t be combined with other formats and requires AI Gateway 2.2 or later. To accept OpenAI-format clients and translate them to Anthropic instead, use formats: [{type: openai}] with a model selector, as the Cursor recipe does.
route.paths and strip_path: true: Claude Code appends /v1/messages to ANTHROPIC_BASE_URL. Kong matches the /coding-agents-anthropic prefix, strips it, and forwards /v1/messages to the upstream.
route.methods: Claude Code sends POST for inference. OPTIONS allows preflight requests from browser-based clients.
targets[].config.upstream_url: The Anthropic API base URL. Kong appends the stripped request path to it.
targets[].config.version: The Anthropic API version, read from ANTHROPIC_VERSION. Claude Code also sends its own anthropic-version header, which passthrough forwards unchanged.
max_request_body_size: 16777216: Raises the request body limit to 16 MB from the 8 MB default. Claude Code requests carry the full conversation, tool definitions, and file contents, and long sessions can exceed the default.
response_streaming: allow: Lets Anthropic stream Server-Sent Events back to Claude Code, which renders tokens as they arrive.
logging.payloads: true: Captures full request and response bodies. Claude Code requests include source code and file contents, so payload logging can expose sensitive data in your logging destination. Set it to false if you only need usage metrics.
In production, store credentials in AI Vaults using {vault://backend/key} references rather than environment variables. AI Vaults support HashiCorp Vault, AWS Secrets Manager, GCP Secret Manager, and the Konnect Config Store.