Claude Sonnet 4.6 API usage and code examples
Base URL, authentication, endpoints, and code examples for calling Claude Sonnet 4.6 (model ID: claude-sonnet-4-6) through the API.
Model details
| Model ID | claude-sonnet-4-6 |
|---|---|
| Provider | Anthropic |
| Type | Text |
| Status | Available |
| Context length | 1,000,000 tokens |
| Processing region | Global |
| Pricing | See the model page |
Base URL and authentication
| Format | Base URL | Key header |
|---|---|---|
| OpenAI | https://token.echohub.io/v1 | Authorization: Bearer |
| Anthropic | https://token.echohub.io | x-api-key / Authorization: Bearer |
Create an API key in the console and put it in the ECHO_API_KEY environment variable.
Endpoints
| Method and path | What it does |
|---|---|
POST /v1/chat/completions | Generate a chat reply (Chat Completions API) |
POST /v1/responses | Generate a response (Responses API) |
POST /v1/messages | Generate a chat reply (Messages API) |
Call examples
The same model ID works with both the OpenAI and Anthropic formats.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://token.echohub.io/v1",
api_key=os.environ["ECHO_API_KEY"],
)
res = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Hello"}],
)
print(res.choices[0].message.content)import os
from anthropic import Anthropic
# The Anthropic SDK adds /v1 automatically
client = Anthropic(
base_url="https://token.echohub.io",
api_key=os.environ["ECHO_API_KEY"],
)
msg = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)curl https://token.echohub.io/v1/chat/completions \
-H "Authorization: Bearer $ECHO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [{"role": "user", "content": "Hello"}]
}'