Claude Sonnet 4

Popular
Anthropic
Text & Chat

Anthropic's most capable model. Excellent for complex analysis, coding, math, and creative writing.

Try Claude Sonnet 4 now
Send a single prompt and stream a response inline. Hit Cmd+Enter to submit.
Sign in to try this model with €5 free credits.
Sign in
Press Cmd+Enter to send
Response appears here.
TL;DR·Last updated March 4, 2026

Claude Sonnet 4 is text & chat AI model from Anthropic, priced at €30.00 per 1M input tokens with a 200K tokens context window.

Try Claude Sonnet 4

0.7

Sign in to generate — 50 free credits on sign-up

Examples

See what Claude Sonnet 4 can generate

Code Review

Review this function and suggest improvements: function add(a,b){return a+b}

The function works but could benefit from several improvements. Add TypeScript types for safety: `function add(a: number, b: number): number`. Consider input validation to handle edge cases like NaN or Infinity. You might also add JSDoc comments for documentation. For a utility function, consider making it part of a math utilities module rather than a standalone global function.

Creative Story

Write the opening paragraph of a sci-fi story set on a generation ship that has been traveling for 300 years

Captain Yara Chen pressed her palm against the observation deck glass, feeling the faint vibration of engines that had been running since before her great-great-grandmother was born. Outside, the stars looked the same as they always had—unchanged pinpricks against the void—but the ship's AI had confirmed it this morning: Kepler-442b was now close enough to resolve as a pale blue dot on the long-range sensors. Three hundred years of recycled air, artificial seasons, and carefully rationed hope were finally converging on something real.

Pricing

Price per Generation
Per generationFree

API Integration

Use our OpenAI-compatible API to integrate Claude Sonnet 4 into your application.

Install
npm install railwail
JavaScript / TypeScript
import railwail from "railwail";

const rw = railwail("YOUR_API_KEY");

// Simple — just pass a string
const reply = await rw.run("claude-sonnet-4", "Hello! What can you do?");
console.log(reply);

// With message history
const reply2 = await rw.run("claude-sonnet-4", [
  { role: "system", content: "You are a helpful assistant." },
  { role: "user", content: "Explain quantum computing simply." },
]);
console.log(reply2);

// Full response with usage info
const res = await rw.chat("claude-sonnet-4", [
  { role: "user", content: "Hello!" },
], { temperature: 0.7, max_tokens: 500 });
console.log(res.choices[0].message.content);
console.log(res.usage);
Specifications
Context window
200,000 tokens
Max output
8,192 tokens
Avg. latency
3.0s
Developer
Anthropic
Category
Text & Chat
Tags
popular
coding
analysis

Deep dive — Anthropic's Claude Sonnet 4

About Anthropic
Founded 2021 · San Francisco, USA

Anthropic was founded in 2021 by Dario and Daniela Amodei alongside ex-OpenAI researchers including Tom Brown and Jared Kaplan. The company is a Public Benefit Corporation focused on AI safety, interpretability and steerability. Foundational papers from the team include 'Scaling Laws for Neural Language Models' (Kaplan et al., 2020), 'Training a Helpful and Harmless Assistant' (2022) and 'Constitutional AI' (2022). The Claude product family was launched in March 2023 starting with Claude 1, followed by Claude 2, the Claude 3 family in March 2024, Claude 3.5 Sonnet in mid-2024, Claude 3.7 Sonnet with extended thinking in early 2025 and the Claude 4 family (Opus 4 and Sonnet 4) in May 2025. Anthropic is backed by Google, Amazon, Spark Capital, Lightspeed and others, with cumulative funding above $15 billion and a 2025 valuation above $60 billion. Anthropic publishes a Responsible Scaling Policy that defines ASL safety levels and is widely cited in AI governance debates.

Visit Anthropic →
Architecture
Decoder-only Transformer (balanced production model)

Claude Sonnet 4 is the mid-tier flagship in the Claude 4 family, positioned as the default daily-driver model balancing latency, cost and capability. Architecturally it is a decoder-only Transformer pretrained on a curated multilingual corpus of web data, source code, books and licensed datasets, with a March 2025 data cutoff. Post-training applies a combination of supervised fine-tuning, Reinforcement Learning from Human Feedback (RLHF), Constitutional AI for harmlessness, and Reinforcement Learning from AI Feedback to scale alignment work. Sonnet 4 supports extended thinking with adjustable thinking budgets, allowing developers to trade additional latency for stronger reasoning on demand. Tool use, parallel tool calls, structured JSON output and Anthropic's computer use API are supported natively. Multimodal training jointly grounds images and text so charts, screenshots and PDF pages can be reasoned about within the 200K context. Sonnet 4 is co-trained alongside Opus 4 using shared infrastructure, then distilled and specialised toward throughput rather than maximum capability. Anthropic evaluated the model under Responsible Scaling Policy ASL-3 safeguards with internal red-teaming and external partners such as METR and Apollo Research before public release.

Parameters
Undisclosed (estimated mid-hundred billion parameters dense)
Context
200K tokens
What it can do
  • Strong coding model with high SWE-bench Verified scores at production cost
  • Optional extended thinking mode with configurable token budget
  • 200K context window with reliable long-document recall
  • Multimodal input including images, charts and PDFs
  • Tool use, parallel tool calls and computer use API
  • Stable agent loops over hours of autonomous work
  • Strict JSON, XML and schema-constrained output
  • Excellent at instruction following and persona retention
  • Multilingual reasoning across major European and Asian languages
  • Low refusal rate on benign technical content thanks to Constitutional AI tuning
  • Best for: production assistants, coding copilots, agent backbones, document analysis at scale.
Training & License

Pretrained on a multi-trillion-token mixture of curated web text, books, code repositories, licensed data and synthetic data, with quality and deduplication filters. Data cutoff is March 2025. Post-training uses human preference data, Constitutional AI critiques and RLAIF on top of supervised fine-tuning.

License: Proprietary commercial license via Anthropic API, Amazon Bedrock and Google Vertex AI.

Known limitations
  • No native audio or video input
  • Knowledge cutoff March 2025
  • Will refuse some dual-use security questions
  • No customer fine-tuning available
  • Not as strong as Opus 4 on hardest math/coding benchmarks

Frequently asked questions

Start using Claude Sonnet 4 today

Get started with free credits. No credit card required. Access Claude Sonnet 4 and 100+ other models through a single API.