Model and Modality PlaybooksOctober 21, 2026Flatkey Team

Claude Sonnet API (2026): Model IDs, Setup, Limits, and Code for Sonnet 5.5

Everything to call Claude Sonnet 5.5 through the API: model IDs, keys, working code, effort and thinking settings, rate limits, costs, and migration fixes.

Claude Sonnet API (2026): Model IDs, Setup, Limits, and Code for Sonnet 5.5

To use the Claude Sonnet API, create an Anthropic API key, then send a request to https://api.anthropic.com/v1/messages with the model ID claude-sonnet-5-5, the current Sonnet model released on September 28, 2026. It has a 1M-token context window, 128K max output, adaptive thinking on by default, and costs $2 per million input tokens and $10 per million output tokens on Anthropic's official pricing, as of October 21, 2026. If you are moving code from Sonnet 4.6 or older, five request settings that used to work now return a 400 error; they are listed below.

This guide is for developers shipping a product on Claude: which Sonnet model ID to call, how to get a key, working code in curl, Python, and Node.js, rate limits by tier, and the breaking changes that trip up migrations. For a full cost breakdown across every Claude model, see our Claude API pricing guide.

Claude Sonnet models available through the API

Model API model ID Status (Oct 21, 2026) Context / max output Input / output per 1M tokens Cache read
Claude Sonnet 5.5 claude-sonnet-5-5 Current, released Sep 28, 2026 1M / 128K $2 / $10 $0.10
Claude Sonnet 5 claude-sonnet-5 Legacy see model docs $2 / $10 $0.20
Claude Sonnet 4.6 claude-sonnet-4-6 Legacy see model docs $3 / $15 $0.30
Claude Sonnet 4.5 claude-sonnet-4-5-20250929 Deprecated, retires Nov 30, 2026 see model docs $3 / $15 $0.30

Prices from Anthropic's pricing page; model status from the models overview and deprecations page; Sonnet 5.5 specs from the Sonnet 5.5 overview, all checked October 21, 2026.

Which one to call: use claude-sonnet-5-5 for new work. It costs the same as Sonnet 5 per token but half as much for cache reads ($0.10 vs $0.20 per million), according to the migration guide. Against Sonnet 4.6 ($3 / $15), Sonnet 5.5 is cheaper per token, but note the tokenizer: Anthropic says Sonnet 5.5 produces about 30% more tokens than Sonnet 4.6 for the same text, so compare real token counts, not list prices. Sonnet 4.5 users must move before its November 30, 2026 retirement.

Sonnet 5.5 at a glance

Spec Value Source
Model ID (Claude API, Google Cloud, Microsoft Foundry, Claude Platform on AWS) claude-sonnet-5-5 Overview
Amazon Bedrock model ID anthropic.claude-sonnet-5-5 Overview
Context window 1M tokens Overview
Max output 128K tokens; 300K on the Batch API with beta header output-300k-2026-03-24 Overview
Input / output modalities Text and images in, text out Overview
Thinking Adaptive, on by default; lowest setting between_tools Overview
Default effort high Overview
Knowledge cutoff June 2026 Overview
Retirement Not sooner than September 28, 2027 Overview

How to get a Claude Sonnet API key

  1. Sign in to the Claude Console and open API keys.
  2. Create a key, copy it once, and store it as ANTHROPIC_API_KEY in your environment or secret manager.
  3. Add credit or a payment method. Usage tier (and rate limits) rises with spend; see the rate limits section below.

One key works for every Claude model, so there is no separate "Sonnet API key." If you would rather use one key for Claude, GPT, Gemini, and DeepSeek, a unified API such as Flatkey issues a single key for all of them (covered at the end).

Your first Claude Sonnet 5.5 request

The request below follows Anthropic's official example in the Sonnet 5.5 migration guide. It sets an effort level and avoids all settings that return a 400 on this model.

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 4096,
    "messages": [{"role": "user", "content": "Write a SQL query that finds churned customers in the last 30 days."}],
    "output_config": {"effort": "medium"}
  }'

Python, using the official anthropic SDK:

# pip install anthropic
import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY

response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=4096,
    messages=[{"role": "user", "content": "Write a SQL query that finds churned customers in the last 30 days."}],
    output_config={"effort": "medium"},
)

print("stop_reason:", response.stop_reason)
for block in response.content:
    if block.type == "text":  # adaptive thinking may add thinking blocks first
        print(block.text)

Node.js with @anthropic-ai/sdk:

// npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic(); // reads ANTHROPIC_API_KEY

const response = await client.messages.create({
  model: "claude-sonnet-5-5",
  max_tokens: 4096,
  messages: [{ role: "user", content: "Write a SQL query that finds churned customers in the last 30 days." }],
  output_config: { effort: "medium" },
});

const text = response.content.find((b) => b.type === "text");
console.log(response.stop_reason, text?.text);

Read the response by block type. With adaptive thinking on, the first content block can be a thinking block, so response.content[0].text is not safe on Sonnet 5.5.

Effort and thinking on Sonnet 5.5

Sonnet 5.5 replaces fixed thinking budgets with an effort setting in output_config (effort docs). The default is high. Anthropic's migration guide shows the levels low, medium, high, xhigh, and max.

You want Send Notes from Anthropic's docs
Default behavior nothing, or thinking: {"type": "adaptive"} Adaptive thinking is on by default
Cheaper, faster answers output_config: {"effort": "low"} or "medium" Lower effort means fewer output tokens
No up-front thinking thinking: {"type": "between_tools"} Accepted at low, medium, high; returns 400 at xhigh or max
Hardest problems output_config: {"effort": "xhigh"} or "max" Use adaptive thinking, not between_tools

thinking: {"type": "disabled"} is not accepted on Sonnet 5.5; between_tools is the lowest setting (migration guide).

Settings that now return a 400 error

If you are upgrading from Sonnet 4.6 or earlier, remove these. All five are listed in Anthropic's Sonnet 5.5 migration guide:

Old setting On Sonnet 5.5 Replace with
thinking: {"type": "enabled", "budget_tokens": N} 400 error output_config.effort
temperature, top_p, top_k 400 error Prompt instructions; effort
Assistant prefill (last message from assistant) 400 error Structured outputs or system instructions
Forced tool_choice (any or a named tool) 400 error auto plus clear tool instructions
thinking: {"type": "disabled"} 400 error thinking: {"type": "between_tools"}

Also re-check max_tokens and cost estimates because of the roughly 30% token increase versus Sonnet 4.6. If you hit model ID errors after an upgrade, our Claude model version not found and Anthropic 400 errors guides cover the common causes.

Claude Sonnet API rate limits

Anthropic publishes per-tier limits on its rate limits page. For Sonnet 5.5, as of October 21, 2026:

Tier Requests per minute Input tokens per minute Output tokens per minute
Start 1,000 2,000,000 400,000
Build 5,000 5,000,000 1,000,000
Scale 10,000 10,000,000 2,000,000

Sonnet 5, Sonnet 4.x, and Haiku 5.5 share the same numbers per tier. Anthropic notes that cached input tokens do not count toward input-tokens-per-minute limits for most models, which makes prompt caching a rate-limit tool as well as a cost tool.

What Sonnet 5.5 costs in practice

Official prices on October 21, 2026, per 1M tokens (pricing):

Item Price
Input $2.00
Output $10.00
Cache write, 5 minutes $2.50
Cache write, 1 hour $4.00
Cache read $0.10
Batch API input / output $1.00 / $5.00
US-only inference (inference_geo) 1.1x all token prices

Worked example: a support assistant handling 50,000 requests a month, each with a 3,000-token cached system prompt, 500 new input tokens, and 400 output tokens. Cache reads: 150M tokens x $0.10 = $15. New input: 25M x $2 = $50. Output: 20M x $10 = $200. Total about $265 a month, before the one-off cache writes. Output dominates, which is why effort matters more than input optimization. For model-by-model comparisons, use Claude API pricing and Claude vs GPT API routing.

Using Claude Sonnet with the OpenAI SDK

Anthropic offers an OpenAI-compatible endpoint at https://api.anthropic.com/v1/, but its OpenAI SDK compatibility page describes it as meant for testing and comparison, not most production use: the strict parameter for function calling is ignored, response_format is ignored, and prompt caching is not supported there. For production on Sonnet 5.5, use the native Messages API above. Our Claude API OpenAI SDK compatibility post covers the options in detail.

One key for Sonnet and other models: Flatkey

If your product also calls GPT, Gemini, or DeepSeek, Flatkey gives you one key and one prepaid balance for all of them. On October 21, 2026, Flatkey's model page for Claude Sonnet 5.5 listed $1.60 input / $8.00 output per 1M tokens, 20% below Anthropic's $2 / $10, and Sonnet 4.6 at $2.40 / $12.00. The Anthropic SDK works by changing the base URL to https://router.flatkey.ai (no /v1), per Flatkey's Anthropic SDK guide:

import anthropic

client = anthropic.Anthropic(api_key="YOUR_FLATKEY_KEY", base_url="https://router.flatkey.ai")
msg = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Draft a release note for v2.3."}],
)
print(next(b.text for b in msg.content if b.type == "text"))

For Claude Code setups, see Claude Code API router setup. Use Anthropic directly if you need features or contracts only available on its own platform, such as specific beta headers on launch day or an enterprise agreement.

For when Sonnet is the right coding model and when Opus or Haiku fits better, read which Claude model is best for coding.

FAQ

What is the Claude Sonnet API model name?

The current model ID is claude-sonnet-5-5 on the Claude API, Google Cloud, Microsoft Foundry, and Claude Platform on AWS, and anthropic.claude-sonnet-5-5 on Amazon Bedrock, as of October 21, 2026. Older IDs include claude-sonnet-5 and claude-sonnet-4-6.

How much does the Claude Sonnet API cost?

Claude Sonnet 5.5 costs $2 per million input tokens and $10 per million output tokens, with cache reads at $0.10 and the Batch API at half price ($1 / $5), on Anthropic's pricing page checked October 21, 2026.

Is the Claude Sonnet API free?

No. Anthropic's API is paid per token; there is no free API tier for Sonnet. The consumer Claude apps have their own free and paid plans, which are separate from API billing. For free options from other providers, see our free LLM API guide.

What is the context window of Claude Sonnet 5.5?

1M tokens, with up to 128K output tokens per request, or 300K on the Message Batches API with the output-300k-2026-03-24 beta header.

Why does my Sonnet request return a 400 error after upgrading?

Sonnet 5.5 rejects thinking budgets, temperature/top_p/top_k, assistant prefill, forced tool choice, and thinking: {"type": "disabled"}. Remove them and use output_config.effort or thinking: {"type": "between_tools"} instead.

Is there a Claude Sonnet 5 API?

Yes. claude-sonnet-5 is still callable as a legacy model at $2 / $10 per million tokens, with cache reads at $0.20. Sonnet 5.5 has the same token prices and half-price cache reads, so it is the better default for new work.

Sources