Claude-Sonnet-4 API

Claude Sonnet 4 excels in coding, reasoning, and analytics. Anthropic’s model offers precise API solutions for developers and enterprises.

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

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.

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."
    }
  ]
}'

Related articles

All posts

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.

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."
    }
  ]
}'