For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DashboardSign Up
  • Getting Started
    • Welcome
    • Quick Start
    • Authentication
  • Native Mode
    • Overview
    • OpenAI
    • Anthropic
    • Gemini
  • Unified Mode
    • Overview
    • Python
    • TypeScript
    • cURL
  • Platform
    • Key Management
    • Rate Limits & Budgets
    • Usage & Billing
    • Error Reference
  • API Reference
DashboardSign Up
On this page
  • Setup
  • Basic message
  • Streaming
  • Tool use
  • System prompts
  • TypeScript
  • Notes
  • Supported models
Native Mode

Anthropic (Native Mode)

Use the Anthropic SDK with Gateway AI
Was this page helpful?
Edit this page
Previous

Gemini (Native Mode)

Use the Google Gemini API with Gateway AI
Next
Built with

Setup

Install the Anthropic SDK:

$pip install anthropic

Configure the client:

1import anthropic
2
3client = anthropic.Anthropic(
4 api_key="sk-proxy-YOUR_KEY_HERE",
5 base_url="https://api.trygateway.ai/anthropic"
6)

Basic message

1message = client.messages.create(
2 model="claude-sonnet-4-6",
3 max_tokens=1024,
4 messages=[
5 {"role": "user", "content": "Explain quantum computing in one paragraph."}
6 ]
7)
8
9print(message.content[0].text)

Streaming

1with client.messages.stream(
2 model="claude-sonnet-4-6",
3 max_tokens=1024,
4 messages=[{"role": "user", "content": "Write a haiku about APIs."}]
5) as stream:
6 for text in stream.text_stream:
7 print(text, end="")

Tool use

1message = client.messages.create(
2 model="claude-sonnet-4-6",
3 max_tokens=1024,
4 tools=[
5 {
6 "name": "get_weather",
7 "description": "Get the current weather for a location",
8 "input_schema": {
9 "type": "object",
10 "properties": {
11 "location": {"type": "string", "description": "City name"}
12 },
13 "required": ["location"]
14 }
15 }
16 ],
17 messages=[{"role": "user", "content": "What's the weather in Tokyo?"}]
18)
19
20for block in message.content:
21 if block.type == "tool_use":
22 print(f"Tool: {block.name}, Input: {block.input}")

System prompts

1message = client.messages.create(
2 model="claude-sonnet-4-6",
3 max_tokens=1024,
4 system="You are a senior software engineer. Be concise and precise.",
5 messages=[{"role": "user", "content": "Review this function: def add(a, b): return a + b"}]
6)

TypeScript

1import Anthropic from "@anthropic-ai/sdk";
2
3const client = new Anthropic({
4 apiKey: "sk-proxy-YOUR_KEY_HERE",
5 baseURL: "https://api.trygateway.ai/anthropic",
6});
7
8const message = await client.messages.create({
9 model: "claude-sonnet-4-6",
10 max_tokens: 1024,
11 messages: [{ role: "user", content: "Hello!" }],
12});
13
14console.log(message.content[0].text);

Notes

  • anthropic-version header: The gateway automatically sets anthropic-version: 2023-06-01 if your request doesn’t include one.
  • All Anthropic features are supported: vision, tool use, extended thinking, batches — the request is proxied unmodified.

Supported models

  • claude-opus-4-6, claude-sonnet-4-6
  • claude-opus-4-5, claude-haiku-4-5

New Anthropic models work automatically.