Claude-Sonnet-4 API

anthropic/claude-sonnet-4
Claude Sonnet 4 excels in coding, reasoning, and analytics. Anthropic’s model offers precise API solutions for developers and enterprises.
Context
1M tokens
Input
$4.1262 / 1M tokens
Output
$20.631 / 1M tokens
Released
May 22, 2025

Overview

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.

Technical Specifications

Performance Benchmarks

Claude Sonnet 4 balances efficiency and performance for coding and reasoning.

  • Context Window: 200K tokens.
  • Output Capacity: Up to 64K tokens per response.
  • Performance Benchmarks: SWE-bench: 72.7%, Terminal-bench: 35.5%.
  • API Pricing:
    • Input tokens: $3.9 per million tokens.
    • Output tokens: $19.5 per million tokens.
    • Cost for 1,000 tokens: $0.00315 (input) + $0.01575 (output) = $0.0189 total.

Performance Metrics

Sonnet 4 Metrics

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.

Code Samples

Limitations

  • No vision capabilities.
  • No fine-tuning support.
  • Limited to text-based tasks.

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

‍

How to use Claude-Sonnet-4 API

Install any OpenAI-compatible SDK, point it at api.aimlapi.com/v1, and set the model to anthropic/claude-sonnet-4.

OpenAI-compatible — swap the base URL and it works with your existing SDK.

Claude-Sonnet-4 API Pricing

TypePrice
Input
$4.1262 / 1M tokens
Output
$20.631 / 1M tokens
Cached input
$0.41262 / 1M tokens

Claude-Sonnet-4 Benchmarks

BenchmarkScoreWhat it measuresSourceRetrieved
OSWorld
42.2%
Computer-use across real desktop applicationsSourceJuly 8, 2026
SWE-bench Verified
72.7%
Resolving verified real GitHub issuesSourceJuly 8, 2026
Intelligence
18.9
Composite score across standardised reasoning, knowledge and problem-solving evaluations, measured independently by Artificial AnalysisSourceSeptember 12, 2026
Coding
37.6
Composite score across standardised coding evaluations, measured independently by Artificial AnalysisSourceSeptember 12, 2026
Math
74.3
Composite score across standardised mathematics evaluations, measured independently by Artificial AnalysisSourceSeptember 12, 2026

Claude-Sonnet-4 vs other models

ModelInputOutputContextBest for
$4.1262 / 1M tokens
$20.631 / 1M tokens
1M tokens
$6.5 / 1M tokens
$39 / 1M tokens
1M tokens
Reasoning + agents
$2.6 / 1M tokens
$13 / 1M tokens
1M tokens
Balanced coding + agents
$3.9 / 1M tokens
$19.5 / 1M tokens
1M tokens
Long-context, multimodal & agentic workflows
$1.95 / 1M tokens
$11.7 / 1M tokens
1M tokens
Reasoning + agents

Frequently asked questions

Yes, Claude-Sonnet-4 can stream responses as they are generated.

Yes, Claude-Sonnet-4 supports both function calling and structured outputs.

Claude-Sonnet-4 was built by Anthropic.

Yes, Claude-Sonnet-4 includes web search capability.

Start building with Claude-Sonnet-4

Get API Key
1000+ models, one API.