[Anthropic](/ai-gateway/models/labs/anthropic)

# Claude Sonnet 4

Claude Sonnet 4 supports a context window of 1M tokens on 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. Your use is subject to Anthropic's [Terms](https://www.anthropic.com/legal/commercial-terms) & [Privacy](https://privacy.anthropic.com/en/) Policies.

File InputReasoningTool UseVision (Image)Explicit Caching

[Use with AI Gateway](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Futm_source%3Dgateway-model-page%26utm_campaign%3Dai-gateway-models&title=Get+Started+with+Vercel+AI+Gateway) [View docs](https://vercel.com/docs/ai-gateway)

AI SDKChat CompletionsMessagesResponses

```
1import { streamText } from 'ai'
2

3const result = streamText({
4  model: 'anthropic/claude-sonnet-4',
5  prompt: 'Why is the sky blue?'
6})
```

[Read docs](https://vercel.com/docs/ai-gateway/sdks-and-apis/ai-sdk)

[Overview](/ai-gateway/models/claude-sonnet-4) [API](/ai-gateway/models/claude-sonnet-4/api) [About](/ai-gateway/models/claude-sonnet-4/about) [Providers](/ai-gateway/models/claude-sonnet-4/providers) [Throughput](/ai-gateway/models/claude-sonnet-4/throughput) [Latency](/ai-gateway/models/claude-sonnet-4/latency) [Uptime](/ai-gateway/models/claude-sonnet-4/uptime) [Status](/ai-gateway/models/claude-sonnet-4/status) [Similar](/ai-gateway/models/claude-sonnet-4/similar) [FAQ](/ai-gateway/models/claude-sonnet-4/faq)

## [Copy link to heading](#playground)Playground

Try out Claude Sonnet 4 by Anthropic. Usage is billed to your team at API rates. Free users (those who haven't made a payment) get $5 of credits every 30 days.

![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75)Claude Sonnet 4

![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=96&q=75)

Claude Sonnet 4

## [Copy link to heading](#providers)Providers

Route requests across multiple providers. Copy a provider slug to set your preference. Visit the [docs](/docs/ai-gateway/provider-options) for more info. Using a provider means you agree to their terms, listed under Legal.

| Provider |
| --- |

| Context | Max Output | Latency | Throughput | Input | Output | Cache | Web Search | Capabilities | ZDR | No Training | Free Tier | Release Date |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |

| ![bedrock logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Famazon%2520bedrock.png&w=48&q=75) [Bedrock](/ai-gateway/models/providers/bedrock) Legal:[Terms](https://aws.amazon.com/service-terms/)•[Privacy](https://aws.amazon.com/privacy/) | 1M | 8K | 0.8s | 87tps | $3/M+1 more | $15/M+1 more | Read: $0.30/M+1 more Write: $3.75/M+2 more | — | +2 |  |  |  | 05/22/2025 |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| ![vertexAnthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fvertex%2520ai.png&w=48&q=75) [Google Vertex AI](/ai-gateway/models/providers/vertex) Legal:[Terms](https://cloud.google.com/terms)•[Privacy](https://cloud.google.com/terms/cloud-privacy-notice) | 1M | 8K | 0.7s |  | $3/M+1 more | $15/M+1 more | Read: $0.30/M+1 more Write: $3.75/M+2 more | $10/K \+ input costs | +2 |  |  |  | 05/22/2025 |  |

## [Copy link to heading](#throughput)Throughput24 hours

1W

1D

P50 throughput on live AI Gateway traffic, in tokens per second (TPS). Visit the [docs](https://vercel.com/docs/ai-gateway/models-and-providers/metrics) for more info.

## [Copy link to heading](#latency)Latency24 hours

1W

1D

P50 time to first token (TTFT) on live AI Gateway traffic, in milliseconds. View the [docs](https://vercel.com/docs/ai-gateway/models-and-providers/metrics) for more info.

## [Copy link to heading](#uptime)Uptime24 hours

1W

1D

1H

Direct request success rate on AI Gateway and per-provider. Visit the [docs](https://vercel.com/docs/ai-gateway/models-and-providers/uptime) for more info.

1W

1D

1H

## [Copy link to heading](#more-models-by-anthropic)More models by Anthropic

All

Text

Code

| Model |
| --- |

| Context | Latency | Throughput | Input | Output | Cache | Web Search | Capabilities | Providers | ZDR | No Training | Free Tier | Release Date |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |

| ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) [anthropic/claude-opus-5](/ai-gateway/models/claude-opus-5) | 1M | 1.8s | 115tps | $5/MFast $10/M | $25/MFast $50/M | Read:$0.50/M Write: $6.25/M+1 more | $10/K \+ input costs | +3 | ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) ![bedrock logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Famazon%2520bedrock.png&w=48&q=75) ![claudeaws logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) +1 |  |  |  | 07/24/2026 |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) [anthropic/claude-sonnet-5](/ai-gateway/models/claude-sonnet-5) | 1M | 1.3s | 118tps | $2/M | $10/M | Read:$0.20/M Write: $2.50/M+1 more | $10/K \+ input costs | +3 | ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) ![bedrock logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Famazon%2520bedrock.png&w=48&q=75) ![claudeaws logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) +1 |  |  |  | 06/29/2026 |  |
| ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) [anthropic/claude-opus-4.8](/ai-gateway/models/claude-opus-4.8) | 1M | 0.9s | 103tps | $5/MFast $10/M | $25/MFast $50/M | Read:$0.50/M Write: $6.25/M+1 more | $10/K \+ input costs | +3 | ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) ![bedrock logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Famazon%2520bedrock.png&w=48&q=75) ![claudeaws logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) +1 |  |  |  | 05/28/2026 |  |
| ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) [anthropic/claude-sonnet-4.6](/ai-gateway/models/claude-sonnet-4.6) | 1M | 1.0s | 64tps | $3/M | $15/M | Read:$0.30/M Write: $3.75/M+1 more | $10/K \+ input costs | +3 | ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) ![bedrock logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Famazon%2520bedrock.png&w=48&q=75) ![claudeaws logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) +1 |  |  |  | 02/17/2026 |  |
| ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) [anthropic/claude-opus-4.6](/ai-gateway/models/claude-opus-4.6) | 1M | 1.1s | 52tps | $5/MFast $30/M | $25/MFast $150/M | Read:$0.50/M Write: $6.25/M+1 more | $10/K \+ input costs | +3 | ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) ![bedrock logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Famazon%2520bedrock.png&w=48&q=75) ![vertexAnthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fvertex%2520ai.png&w=48&q=75) |  |  |  | 02/05/2026 |  |
| ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) [anthropic/claude-haiku-4.5](/ai-gateway/models/claude-haiku-4.5) | 200K | 0.6s | 111tps | $1/M | $5/M | Read:$0.10/M Write: $1.25/M+1 more | $10/K \+ input costs | +3 | ![anthropic logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) ![bedrock logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Famazon%2520bedrock.png&w=48&q=75) ![claudeaws logo](/vc-ap-vercel-marketing/_next/image?url=https%3A%2F%2F7nyt0uhk7sse4zvn.public.blob.vercel-storage.com%2Fdocs-assets%2Fstatic%2Fdocs%2Fai-gateway%2Flogos%2Fanthropic.png&w=48&q=75) +1 |  |  |  | 10/15/2025 |  |

## [Copy link to heading](#about-claude-sonnet-4)About Claude Sonnet 4

Claude Sonnet 4 launched on May 22, 2025 alongside Claude Opus 4, positioned as a significant upgrade over Claude Sonnet 3.7 with stronger coding, reasoning, and instruction-following precision. It scored 72.7% on SWE-bench Verified, matching or exceeding Opus 4's 72.5% on the coding benchmark central to software engineering teams. GitHub announced it would power the coding agent in GitHub Copilot. Manus highlighted improvements in complex instruction following and aesthetic outputs. iGent reported navigation errors dropping from 20% to near zero.

The context window of 1M tokens lets you process full codebases of approximately 75,000 lines of code or equivalently large document sets in a single request. Enable this by adding the `anthropic-beta: context-1m-2025-08-07` request header and routing through the Anthropic provider specifically.

Claude Sonnet 4 is a hybrid model offering both near-instant standard responses and extended thinking for deeper reasoning. Extended thinking with tool use is also available in beta. Both Claude Sonnet 4 and Opus 4 can use tools in parallel. The Claude 4 generation introduced one-hour prompt caching as an API capability. Steerability was a highlighted design improvement: the model responds more precisely to instructions, reducing the gap between what you ask and what you get.

The 65% reduction in shortcut-taking behavior compared to Sonnet 3.7 also applies to Claude Sonnet 4, improving reliability in production agentic deployments.

## [Copy link to heading](#what-to-consider-when-choosing-a-provider)What To Consider When Choosing a Provider

- Configuration: The context window of 1M tokens increases per-request token volumes. Monitor cost per request when processing full codebases or large document collections, since a single request can consume tokens equivalent to many standard calls.
- Zero Data Retention: Zero Data Retention is available for this model. It is offered on a per-provider and model basis. See the [documentation](https://vercel.com/docs/ai-gateway/security-and-compliance/zdr) for details.
- Authentication: AI Gateway authenticates requests using an [API key](https://vercel.com/docs/ai-gateway/authentication-and-byok#api-key-authentication) or [OIDC token](https://vercel.com/docs/ai-gateway/authentication-and-byok#oidc-token-authentication). You do not need to manage provider credentials directly.

## [Copy link to heading](#when-to-use-claude-sonnet-4)When to Use Claude Sonnet 4

### Best for

- Full-codebase analysis: The context window of 1M tokens lets you pass an entire large repository in a single request
- Agentic coding at scale: SWE-bench 72.7% and GitHub Copilot's selection as its coding agent model speak directly to this use case
- Multi-file refactoring: Architectural reasoning where the model needs to hold the whole picture simultaneously
- Instruction-precise applications: Improved steerability follows complex, nuanced instructions more accurately
- Agent workflows at Sonnet pricing: Lower per-token cost than Opus 4 makes Claude Sonnet 4 the right choice when benchmark results are comparable

### Consider alternatives when

- Provider flexibility: Check whether later model versions support 1M tokens through all providers when you don't want to pin to Anthropic
- Sonnet 4.5 improvements: OSWorld computer use performance, 30+ hour agentic task duration, and domain-specific reasoning advances
- Haiku 4.5 capability match: Lower-cost option when Haiku 4.5 covers the capability requirements
- Opus-level reasoning depth: Sonnet benchmarks don't capture the full difficulty of some problems

## [Copy link to heading](#conclusion)Conclusion

Claude Sonnet 4 pairs strong coding benchmark performance with a context window of 1M tokens that makes entire codebases processable in one shot, a combination that changes what's architecturally feasible for software engineering agents. At Sonnet pricing, it's the default choice for teams building on the Claude 4 generation until their workloads require Opus or the later Sonnet improvements.