Anthropic logo
Anthropic

Claude Sonnet 4.6

Anthropic's latest flagship model, excelling in code generation, analysis, and writing tasks with prompt caching support

Category Text Model ID claude-sonnet-4-6
Context Length200K tokens
Model TypeLarge Language Model (LLM)
MultimodalText, Image Input

Pricing & Specs

💰 Pricing

Input$3 / M tokens
Output$15 / M tokens
Cache Write$3.75 / M tokens
Cache Hit$0.30 / M tokens

⚙️ Specs

Context Length200K tokens
Model TypeLarge Language Model (LLM)
MultimodalText, Image Input
Release DateFebruary 18, 2026
Cache Write5m: $3.75 / MTok; 1h: $6 / MTok
Cache Hit$0.30 / MTok
API CompatibilityClaude API, Claude Code, OpenAI API

API Examples

Python

import anthropic

client = anthropic.Anthropic(
    api_key="your-api-key"
)

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, Claude!"}
    ]
)

print(message.content[0].text)

cURL

curl https://api.xairouter.com/v1/messages
  -H "Content-Type: application/json"
  -H "x-api-key: YOUR_API_KEY"
  -H "anthropic-version: 2023-06-01"
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, Claude!"}
    ]
  }'

Developer Assist

# Set environment variables in terminal
export ANTHROPIC_AUTH_TOKEN=sk-Xvs...  # Your API Key
export ANTHROPIC_BASE_URL=https://api.xairouter.com

# Start Claude Code
claude

# Now you can use claude-sonnet-4-6 model directly for development