Claude Sonnet 4 API

Claude Sonnet 4 is Anthropic’s balanced hybrid reasoning model, built for strong coding, reasoning, instruction following, and tool use.

Modalities
Image, TextText
In / Out price
$3.17/$15.87per 1M
Context window
1M tokens
Released
May 22, 2025

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

DeveloperAnthropic
Model IDanthropic/claude-sonnet-4
Release DateMay 21, 2025
Context Window1,000,000 tokens (~1M)
Max Output Tokens64,000 tokens
ModalitiesImage, Text → Text
Capabilitiesfile 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.

Claude Sonnet 4 API pricing

Claude Sonnet 4 pricing in US dollars
UsagePriceUnit
Input$3.171M tokens
Output$15.871M tokens
Cached input$0.31741M 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.

AI/ML API model prices in USD per million tokens
ModelInputOutput
Claude Sonnet 4$3.17$15.87
Claude Haiku 5.5$0.1$0.5
Claude Sonnet 5.5$2$10
Claude Opus 5.5$4$20
Claude Fable 5.1$10$50

How to use the Claude Sonnet 4 API

View docs

Build with your agent

Give your agent the model details, code and documentation.

1Get your API key

Create API key
export 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."
    }
  ]
}'

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.

Start building with Claude Sonnet 4

Claude Sonnet 4 API

anthropic/claude-sonnet-4

Build with your agent

Give your agent the model details, code and documentation.

1Get your API key

Create API key
export 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."
    }
  ]
}'