Claude-Sonnet-4 overview
Claude-Sonnet-4 by Anthropic
Anthropic’s Claude Sonnet 4 is a precise AI model for coding and reasoning. With a 200K-token context window, it excels in software development.
Claude-Sonnet-4 specs
- Model ID
anthropic/claude-sonnet-4- Developer
- Anthropic
- Context window
- 1,000,000 tokens
- Max output
- 64,000 tokens
- Input
- Image, Text
- Output
- Text
- API
- OpenAI-compatible, base URL
https://api.aimlapi.com/v1
Claude Sonnet 4 Description
Anthropic’s Claude Sonnet 4 is an efficient AI model for coding, reasoning, and analytics. With a 200K-token context window, it offers precise solutions.
Performance Benchmarks
Claude Sonnet 4 balances efficiency and performance for coding and reasoning.
- Output Capacity: Up to 64K tokens per response.
- Performance Benchmarks: SWE-bench: 72.7%, Terminal-bench: 35.5%.
Key Capabilities
Claude Sonnet 4 delivers reliable outputs for diverse workflows.
- Advanced Coding: Excels in code reviews, bug fixes, and multi-file edits.
- Advanced Reasoning: Strong in multi-step reasoning for analytics and problem-solving.
- Tool Utilization: Supports function calling and JSON structuring for API automation.
- API Features: Provides streaming and function calling for scalable applications.
Optimal Use Cases
- Coding: Code reviews, bug fixes, and multi-file code edits.
- Data Analysis: Processing business datasets.
- Business Automation: Streamlining workflows with API integration.
- Complex Problem-Solving: Tackling multi-step reasoning tasks.
Comparison with Other Models
- Vs. Gemini 2.5 Flash: Superior coding accuracy (72.7% vs. 63.8% SWE-bench), ideal for software development.
- Vs. OpenAI o3-mini: Stronger coding performance (72.7% vs. 69.1% SWE-bench), better for efficient coding tasks.
- Vs. Qwen3-235B-A22B: Higher coding precision (72.7% vs. ~60% SWE-bench, estimated), optimized for code efficiency.
API Integration
Accessible via AI/ML API Documentation: available here.
Use cases
- Autonomous coding and large software development projects
- Customer support and enterprise AI agents
- Research and long-form document analysis
- AI-powered writing and content creation
- Interactive AI assistants with enhanced memory and tool capabilities
Capabilities
- File input
- Reasoning
- Streaming
- Vision
- Web search
Claude-Sonnet-4 benchmarks by
Artificial Analysis
See how Claude-Sonnet-4 scores on independent evaluations. Data retrieved Nov 3, 2026.
Benchmark results
Compare 16 models available on AI/ML API across 5 independent benchmarks.
Humanity's Last Exam
Expert-written questions across academic subjects.
GPQA Diamond
Graduate-level science questions written to resist web search.
AA-LCR
Reasoning across long documents of about 100k tokens.
IFBench
Following precise instructions about the shape of the answer.
τ²-Bench Telecom
Customer support agent tasks with tool calls.
Claude-Sonnet-4 API pricing
| Usage | Price | Unit |
|---|---|---|
| Input | $3.17 | 1M tokens |
| Output | $15.87 | 1M tokens |
| Cached input | $0.3174 | 1M tokens |
Prices from the AI/ML API price list, checked on Nov 4, 2026.
Claude-Sonnet-4 vs other models: token prices
AI/ML API input and output rates for 5 models, per million tokens.
| Model | Input | Output |
|---|---|---|
| $3.17 | $15.87 | |
| $0.1 | $0.5 | |
| $2 | $10 | |
| $4 | $20 | |
| $10 | $50 |
How to use the Claude-Sonnet-4 API
View docsBuild with your agent
Give your agent the model details, code and documentation.
1Get your API key
Create API keyexport AIMLAPI_KEY="8f2b4c7d9a1e6b3f…"2Make your first request
curl 'https://api.aimlapi.com/v1/chat/completions' \
-H "Authorization: Bearer $AIMLAPI_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "anthropic/claude-sonnet-4",
"messages": [
{
"role": "user",
"content": "Write a haiku about the ocean."
}
]
}'import os
import requests
headers = {
"Authorization": f"Bearer {os.environ['AIMLAPI_KEY']}",
"Content-Type": "application/json",
}
payload = {
"model": "anthropic/claude-sonnet-4",
"messages": [
{
"role": "user",
"content": "Write a haiku about the ocean."
}
]
}
response = requests.post("https://api.aimlapi.com/v1/chat/completions", headers=headers, json=payload, timeout=120)
response.raise_for_status()
print(response.json())const response = await fetch("https://api.aimlapi.com/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AIMLAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "anthropic/claude-sonnet-4",
"messages": [
{
"role": "user",
"content": "Write a haiku about the ocean."
}
]
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());Related articles
Claude-Sonnet-4 FAQ
How much does Claude-Sonnet-4 cost?
Claude-Sonnet-4 costs $3.17 input and $15.87 output per 1M tokens on AI/ML API, billed as you go with no subscription.
Does Claude-Sonnet-4 support streaming?
Yes, Claude-Sonnet-4 can stream responses as they are generated.
Does Claude-Sonnet-4 support tool calling and structured outputs?
Yes, Claude-Sonnet-4 supports both function calling and structured outputs.
Who created Claude-Sonnet-4?
Claude-Sonnet-4 was built by Anthropic.
Can Claude-Sonnet-4 perform web searches?
Yes, Claude-Sonnet-4 includes web search capability.
What is the Claude-Sonnet-4 model ID?
Use anthropic/claude-sonnet-4 as the model parameter. Requests go to the OpenAI-compatible endpoint with your AI/ML API key.
What is the context window of Claude-Sonnet-4?
Claude-Sonnet-4 accepts up to 1,000,000 tokens of context and returns up to 64,000 output tokens.

