Claude Sonnet 4
Claude Sonnet 4 supports a context window of 1M tokens on Vercel AI Gateway, enabling full codebase analysis of 75,000+ lines or large document sets, while scoring 72.7% on SWE-bench Verified with hybrid extended thinking and enhanced steerability.
import { streamText } from 'ai'
const result = streamText({ model: 'anthropic/claude-sonnet-4', prompt: 'Why is the sky blue?'})Frequently Asked Questions
How do I enable the context window of 1M tokens for Claude Sonnet 4 on AI Gateway?
Add the
anthropic-beta: context-1m-2025-08-07header to your request. UnderproviderOptions.gateway, setonlyto['anthropic']so the request routes through the Anthropic provider, which supports the feature.What does the context window of 1M tokens enable in practice?
The context window of 1M tokens lets you process entire codebases, long documents, or extended conversation histories in a single request. This is particularly useful for code review across multiple files, document analysis, and agentic workflows that accumulate context over many steps.
How did Claude Sonnet 4 perform on SWE-bench Verified?
72.7% on SWE-bench Verified, matching or exceeding Claude Opus 4's 72.5% on that specific benchmark.
What is enhanced steerability in Claude Sonnet 4?
Sonnet 4 responds more precisely to instructions, reducing misinterpretation of complex or nuanced prompts. Anthropic highlighted steerability as an explicit design improvement for applications where exact specification of behavior matters.
Does Claude Sonnet 4 support extended thinking?
Yes. Sonnet 4 is a hybrid model that supports both near-instant responses and extended thinking. Extended thinking with tool use, where the model alternates between reasoning and calling tools, is also available in beta.
What is 1-hour prompt caching and does Sonnet 4 support it?
Yes. The Claude 4 launch introduced one-hour prompt caching as a new API capability, compared to shorter-lived caching in previous generations. This is particularly useful for codebases or large system prompts that appear in many requests.
Why would I use Sonnet 4 instead of Opus 4 given the SWE-bench scores are similar?
Claude Sonnet 4 is priced at the Sonnet tier, while Opus 4 is priced at the Opus tier. When benchmark results are comparable, the cost gap determines the choice at scale. Check the pricing panel on this page for current rates.