Skip to main content

Anthropic

You're reading AI Gateway 2026.09.24. The newest release is 1.2.0. Go to the newest release

Connect the AI Gateway to the Anthropic API. You end up with an LLM Provider that holds your Anthropic credentials, exposes the Messages endpoint through the gateway, and can be consumed by any LLM proxy.

This page is for platform administrators, who hold the upstream credentials.

Connection details​

The anthropic template and these connection settings apply to every Anthropic provider you create:

SettingValue
Template IDanthropic
Upstream URLhttps://api.anthropic.com
Auth typeapi-key
Auth headerx-api-key

Anthropic reads the key from a dedicated x-api-key header, so the value is the key on its own with no prefix.

Configure the provider​

Replace <anthropic-api-key> with your Anthropic API key and deploy the provider:

curl -X POST http://localhost:9090/api/management/v1/llm-providers \
-H "Content-Type: application/yaml" \
-u "$ADMIN_USERNAME:$ADMIN_PASSWORD" \
--data-binary @- <<'EOF'
apiVersion: gateway.api-platform.wso2.com/v1
kind: LlmProvider
metadata:
name: anthropic-provider
spec:
displayName: Anthropic Provider
version: v1.0
template: anthropic
context: /providers/anthropic
upstream:
url: https://api.anthropic.com
auth:
type: api-key
header: x-api-key
value: <anthropic-api-key>
accessControl:
mode: deny_all
exceptions:
- path: /v1/messages
methods: [POST]
EOF

The accessControl block restricts which upstream paths the provider exposes. This provider denies everything except POST /v1/messages.

The context value sets the URL prefix the provider answers on, so this provider serves the Messages endpoint under /providers/anthropic.

Test the provider​

Anthropic providers are exercised through an LLM proxy rather than called directly, because the proxy translates between the OpenAI request format your application sends and the Anthropic Messages format the upstream expects.

To build that proxy and send it a request, see Multi-provider routing, which deploys this provider alongside an OpenAI one and selects between them with a request header.

Supported models​

Anthropic publishes its model list in the Anthropic models reference. Any model Anthropic exposes on the endpoint above works through the gateway; set it in the model field of your request.

Provider-specific notes​

Two settings differ from a provider that follows the OpenAI wire format. Both are properties of the Anthropic API, not gateway options:

  • The auth header is x-api-key, not Authorization. Sending the key in Authorization fails at the upstream.
  • The upstream URL carries no version segment. Anthropic puts the version in the request path, so https://api.anthropic.com combines with the /v1/messages path from accessControl. Adding /v1 to the URL produces a doubled /v1/v1/messages path.

When an LLM proxy routes to this provider, the proxy applies a transformer and may add its own authentication between the two. Those settings belong to the proxy, not to the provider shown here.

  • Provider templates — the token and model metadata the anthropic template extracts.
  • Multi-provider routing — the proxy that consumes this provider.
  • OpenAI — the same setup for a provider that uses Authorization and the OpenAI wire format.

Was this page helpful?