Claude Sonnet 4
Anthropic's most capable model. Excellent for complex analysis, coding, math, and creative writing.
Claude Sonnet 4 is text & chat AI model from Anthropic, priced at €30.00 per 1M input tokens with a 200K tokens context window.
0.7
Examples
See what Claude Sonnet 4 can generate
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.
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
API Integration
Use our OpenAI-compatible API to integrate Claude Sonnet 4 into your application.
npm install railwailimport 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);Deep dive — Anthropic's Claude Sonnet 4
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 →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
- 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.
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
Related Models
View all Text & ChatClaude Opus 4
Anthropic's most powerful model. Exceptional at complex analysis, agentic tasks, and extended reasoning.
DeepSeek V3.1
DeepSeek's refreshed V3.1 release. 671B MoE / 37B active. Tops open-weights leaderboards on coding and reasoning.
DeepSeek V4 Pro
DeepSeek's April 2026 flagship. 1.6T MoE / 49B active params, 1M context, rivals top closed-source models on STEM and coding at a fraction of the price.
GPT-4.1
OpenAI's newest flagship model. Improved reasoning, instruction following, and coding over GPT-4o.
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.