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.
route.paths and strip_path: true: Claude Desktop appends /v1/messages to the Gateway base URL. Kong matches the /coding-agents-anthropic prefix, strips it, and forwards /v1/messages to the upstream.
route.methods: Claude Desktop sends POST for inference. The AI Model doesn’t accept GET, so it doesn’t serve GET /v1/models, and Claude Desktop’s model discovery can’t populate the model picker from it. Set an explicit Model list instead, as shown in Configure Claude Desktop.
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.
max_request_body_size: 16777216: Raises the request body limit to 16 MB from the 8 MB default. Requests carry the full conversation, tool definitions, and attached file contents, and long sessions can exceed the default.
response_streaming: allow: Lets Anthropic stream Server-Sent Events back to Claude Desktop, which renders tokens as they arrive.
logging.payloads: true: Captures full request and response bodies. Claude Desktop conversations can include source code, documents, and other sensitive content, so payload logging can expose that 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.