Skip to navigation

The Anthropic connection sends requests to the Anthropic Messages API with your organization’s Anthropic API key. Clients call the route with the Anthropic Messages format, and the gateway forwards each request unchanged, apart from the credentials. This topic lists what’s specific to Anthropic. For the setup steps, which use Anthropic as the example, see Connect an LLM provider.

Target URL

Use https://api.anthropic.com.

Credentials

Enter an Anthropic API key when you set up credentials. The gateway sends it to Anthropic in the x-api-key header and replaces any x-api-key header that the client sent. Callers authenticate to the gateway with their gateway key in fg-api-key, which is why the gateway key doesn’t use x-api-key. For details, see Authenticate requests with Key Auth.

Clients must still send the anthropic-version header. It reaches Anthropic unchanged, and so does anthropic-beta.

Supported endpoints

MethodPathNotes
POST/v1/messagesSupports streaming.
POST/v1/messages/count_tokens
GET/v1/models

These three endpoints are all that Claude Code needs. A request to any other path gets 404. The gateway doesn’t translate between API formats, so an OpenAI chat completions request to an Anthropic route fails.

Model names

The gateway sends the model field exactly as the client wrote it, for example claude-sonnet-4-5. If the connection restricts models, the name must match an entry on the list exactly. For details, see Restrict model and tool access.

Example

curl "BASE_URL/v1/messages" \
-H "fg-api-key: GATEWAY_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 256,
"messages": [{ "role": "user", "content": "Hello" }]
}'

Replace BASE_URL with the route’s base URL and GATEWAY_KEY with your gateway key. For how to find both, see Authenticate and send a request.

Next steps