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

HeaderValueDescription
AuthorizationBearer gw-your-keyYour gateway API key
anthropic-version2023-06-01Anthropic API version (required)
Content-Typeapplication/jsonRequest body format

Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g. claude-sonnet-4-20250514)
messagesarrayYesArray of conversation messages
max_tokensintegerYesMaximum number of tokens to generate
systemstringNoSystem prompt (a top-level field, not part of messages)
streambooleanNoEnable SSE streaming
temperaturenumberNoSampling temperature (0–1)
toolsarrayNoTool definitions (function calling)
thinkingobjectNoExtended 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 thinking parameter)
  • Prompt caching (cache_control in messages)
  • Tool use / function calling (the tools parameter)
  • Vision (images in messages)
  • PDF processing
  • The anthropic-beta header for beta features

Differences from OpenAI Chat Completions

AspectOpenAIAnthropic
Endpoint/v1/chat/completions/v1/messages
System promptInside the messages arrayTop-level system field
Token fieldsprompt_tokens / completion_tokensinput_tokens / output_tokens
SSE formatdata: ... + [DONE]Typed events: message_start, content_block_delta, …
Required headerNoneanthropic-version: 2023-06-01

Both protocols share the same API key, balance and billing. Pick whichever matches the SDK you already use.