Skip to main content

Documentation Index

Fetch the complete documentation index at: https://to11.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Anthropic SDK

This guide shows you how to point the official Anthropic SDK at the to11 gateway. Set the base_url to your gateway’s /v1 endpoint and use the Anthropic messages API as usual.

Python

pip install anthropic
import anthropic

client = anthropic.Anthropic(
    base_url="http://localhost:4000/v1",
    api_key="sk-ant-...",  # your Anthropic API key
)

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello from to11!"}],
)
print(message.content[0].text)

TypeScript / Node.js

npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "http://localhost:4000/v1",
  apiKey: "sk-ant-...", // your Anthropic API key
});

const message = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 256,
  messages: [{ role: "user", content: "Hello from to11!" }],
});
console.log(message.content[0].text);

Streaming

with client.messages.stream(
    model="claude-sonnet-4-6",
    max_tokens=256,
    messages=[{"role": "user", "content": "Count to 10"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
When the upstream provider is Anthropic, the gateway uses the normalised streaming path to parse SSE into canonical events and re-serialise them. Telemetry (TTFT, token counts) is captured identically on both streaming paths.

System messages

Pass a top-level system parameter as you normally would:
message = client.messages.create(
    model="claude-sonnet-4-6",
    system="You are a helpful assistant that speaks only in haiku.",
    max_tokens=256,
    messages=[{"role": "user", "content": "Tell me about the ocean"}],
)

Tool use

Tool definitions follow the Anthropic input_schema format:
message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=256,
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=[{
        "name": "get_weather",
        "description": "Get current weather for a location",
        "input_schema": {
            "type": "object",
            "properties": {
                "location": {"type": "string"}
            },
            "required": ["location"],
        },
    }],
)

Extended thinking

Extended thinking blocks are preserved in Anthropic-format responses when enabled on the model. The thinking content type passes through the gateway as-is.

Cross-format routing

If you route an Anthropic-format request to an OpenAI model, the gateway translates automatically:
# Anthropic SDK format, but targeting an OpenAI model
message = client.messages.create(
    model="gpt-4o",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello!"}],
)
The system parameter is converted to a {"role": "system"} message, and tool definitions are translated to OpenAI’s parameters format.