Claude Sonnet 4 overview
Claude Sonnet 4 by Anthropic
Claude Sonnet 4 is Anthropic's balanced, mid-size model with strong coding and reasoning capabilities.
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
What Is Claude Sonnet 4 API?
Claude Sonnet 4 is Anthropic’s mid-size model, described as a hybrid reasoning model with two modes: near-instant responses and extended thinking for deeper reasoning. It is presented as a balanced model with strong coding and reasoning capabilities.
Anthropic says Claude Sonnet 4 improves on Claude Sonnet 3.7 across multiple areas, especially coding. It is also described as offering greater control over how eagerly it implements changes.
Technical Reference
| Developer | Anthropic |
|---|---|
| Model ID | anthropic/claude-sonnet-4 |
| Release Date | May 21, 2025 |
| Context Window | 1,000,000 tokens (~1M) |
| Max Output Tokens | 64,000 tokens |
| Modalities | Image, Text → Text |
| Capabilities | file input, parallel tool calls, reasoning, streaming, structured (JSON schema) output, tool/function calling, vision, web search |
What Claude Sonnet 4 Brings to the Table
Hybrid reasoning
Uses two modes: near-instant responses and extended thinking for deeper reasoning.
Balanced model
Described as Anthropic’s mid-size balanced model.
Coding focus
Anthropic highlights stronger coding performance and broad coding improvements versus Claude Sonnet 3.7.
Reasoning and instruction following
AWS describes it as having strong coding and reasoning capabilities with improved instruction following.
Where Claude Sonnet 4 Makes the Most Sense
Coding
Recommended for coding workloads and code-related assistance.
In-depth research
Positioned for in-depth research tasks.
Agents
Presented as suitable for agentic workflows and multi-step tool use.
High-volume use
Google Cloud describes it as suitable for high-volume use cases.
Claude Sonnet 4 vs the Alternatives
Claude Sonnet 3.7
Anthropic describes Claude Sonnet 4 as an improvement over Claude Sonnet 3.7, especially for coding.
Claude Opus 4
Anthropic groups Claude Sonnet 4 with Claude Opus 4 as part of the Claude 4 generation of hybrid reasoning models.
Sources: https://www.anthropic.com/news/claude-4 · https://www.anthropic.com/claude/sonnet · https://www.anthropic.com/research/claude-4
Use cases
Claude Sonnet 4 is documented as suitable for customer-facing AI assistants and high-volume tasks. It is also suited to coding work, including code reviews, bug fixes, and broader development workflows.
For larger-scale software work, it is documented as useful for agentic coding and multi-step development tasks, including planning, writing, debugging, and large refactors. It is also suited to AI assistants and near real-time production workloads, where responsiveness and high throughput matter.
Claude Sonnet 4 is documented as useful for knowledge Q&A over large documents, codebases, or datasets. It is also suited to large-scale content generation and analysis, including efficient research and summarization of extensive material.
It is documented as useful for agent-based workflows that maintain context across many tool calls and multi-step processes.
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());Claude Sonnet 4 FAQ
What is the context window of Claude Sonnet 4?
Claude Sonnet 4 has a 1,000,000 tokens context window and can return up to 64,000 tokens.
What inputs and outputs does Claude Sonnet 4 support?
Claude Sonnet 4 takes image, text as input and returns text.
What is the model ID for Claude Sonnet 4?
Use anthropic/claude-sonnet-4 as the model id. Requests go to https://api.aimlapi.com/v1/chat/completions.
When was Claude Sonnet 4 released?
Claude Sonnet 4 became available on May 22, 2025.
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.
Can Claude Sonnet 4 read images?
Yes, Claude Sonnet 4 accepts image input alongside text.
Who created Claude Sonnet 4?
Claude Sonnet 4 was built by Anthropic.
Can Claude Sonnet 4 process images as input?
Yes, Claude Sonnet 4 accepts image and text input alongside text output, and supports vision as a listed capability.
Does Claude Sonnet 4 support calling external tools or functions?
Yes, it supports tool use, including parallel tool calls.