Anthropic API
The Anthropic Messages protocol is supported natively. Point Claude Code, the Anthropic SDK, or any Anthropic-compatible client straight at the gateway.
Endpoint
POST https://api.eclogue.ai/v1/messages Example request
{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "What is the capital of France?"}
]
} Required headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer gw-your-key | Your gateway API key |
anthropic-version | 2023-06-01 | Anthropic API version (required) |
Content-Type | application/json | Request body format |
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (e.g. claude-sonnet-4-20250514) |
messages | array | Yes | Array of conversation messages |
max_tokens | integer | Yes | Maximum number of tokens to generate |
system | string | No | System prompt (a top-level field, not part of messages) |
stream | boolean | No | Enable SSE streaming |
temperature | number | No | Sampling temperature (0–1) |
tools | array | No | Tool definitions (function calling) |
thinking | object | No | Extended thinking configuration |
Example response
{
"id": "msg_abc123",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-20250514",
"content": [
{"type": "text", "text": "The capital of France is Paris."}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 15,
"output_tokens": 9
}
} With curl
curl -X POST https://api.eclogue.ai/v1/messages \
-H "Authorization: Bearer gw-your-key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}' With Python (Anthropic SDK)
import anthropic
client = anthropic.Anthropic(
base_url="https://api.eclogue.ai",
api_key="gw-your-key-here",
)
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text) Streaming
Set "stream": true to receive Anthropic SSE events (message_start, content_block_delta, message_delta, message_stop):
curl -X POST https://api.eclogue.ai/v1/messages \
-H "Authorization: Bearer gw-your-key" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Hello!"}]
}' Configuring Claude Code
Set these environment variables in your shell to point Claude Code at the gateway:
# ~/.bashrc or ~/.zshrc
export ANTHROPIC_BASE_URL=https://api.eclogue.ai
export ANTHROPIC_AUTH_TOKEN=gw-your-key-here
export ANTHROPIC_API_KEY="" # explicitly empty to prevent fallback Claude Code will then send its requests to https://api.eclogue.ai/v1/messages.
Supported features
Every Anthropic feature is proxied through transparently:
- Extended thinking (the
thinkingparameter) - Prompt caching (
cache_controlin messages) - Tool use / function calling (the
toolsparameter) - Vision (images in messages)
- PDF processing
- The
anthropic-betaheader for beta features
Differences from OpenAI Chat Completions
| Aspect | OpenAI | Anthropic |
|---|---|---|
| Endpoint | /v1/chat/completions | /v1/messages |
| System prompt | Inside the messages array | Top-level system field |
| Token fields | prompt_tokens / completion_tokens | input_tokens / output_tokens |
| SSE format | data: ... + [DONE] | Typed events: message_start, content_block_delta, … |
| Required header | None | anthropic-version: 2023-06-01 |
Both protocols share the same API key, balance and billing. Pick whichever matches the SDK you already use.