Anthropic shipped Claude Sonnet 5.5 on September 28, 2026, and the model has already become the default mid-tier pick for developers who need strong coding performance without paying flagship prices. If you have been running production workloads on Claude Sonnet 5 or an older Claude model, the upgrade path is mostly a one-line change, but there are enough new defaults, pricing tiers, and platform-specific identifiers that a wrong assumption can break a deployment or inflate a bill. This tutorial walks through the full setup: creating API access, installing the right SDK, making your first call, turning on prompt caching, running batch jobs, wiring up tool use, and deploying through Amazon Bedrock, Google Cloud Vertex AI, or Microsoft Azure AI Foundry instead of the direct Anthropic API.
By the end you will have a working Claude Sonnet 5.5 API integration, a cost-control setup using prompt caching and batch processing, and a small working project (a pull-request review bot) that ties the pieces together. Every price, benchmark score, and model identifier below comes from Anthropic’s own documentation and platform release notes published between September 28 and October 3, 2026.
What Changed in Claude Sonnet 5.5
Claude Sonnet 5.5 is the second release in Anthropic’s 5.5 model family, arriving a few days after Claude Opus 5.5. It keeps the Claude Sonnet 5 price point exactly where it was, at $2 per million input tokens and $10 per million output tokens, while scoring far higher on Anthropic’s internal Terminal-Bench 4.0 agentic coding benchmark: 70.6% for Sonnet 5.5 against 10.3% for Sonnet 5, according to Anthropic’s own release documentation. On GDPval-AA, Anthropic’s economically-weighted knowledge-work benchmark, Sonnet 5.5 lands within two percentage points of the considerably more expensive Claude Opus 5.5, and the company reports that Sonnet 5.5 generates completed output more than 30% faster than Sonnet 5 at the same price.
That combination, flagship-adjacent reasoning quality at mid-tier pricing, is the reason this specific model has become the one worth setting up first if you are choosing among Anthropic’s current lineup. If you are also evaluating OpenAI’s and Google’s latest releases, our breakdown of Sonnet 5.5 vs GPT-6 Luna vs Gemini 3.8 covers how the three stack up on price and benchmark score side by side, and our GPT-6.1 Sol API setup guide and Gemini 3.8 Flash API setup tutorial use the same step structure as this one, so you can mirror a setup across all three providers if you are running multi-model infrastructure.
Where Claude Sonnet 5.5 Fits: Use Cases Worth Building First
Before writing any code, it is worth being specific about where Claude Sonnet 5.5 actually earns its upgrade over Sonnet 5, rather than installing it everywhere by default. The Terminal-Bench 4.0 jump points directly at agentic, multi-step command-line and coding workflows: tasks where a model has to plan, execute a tool call, read the result, and decide what to do next, repeatedly, without a human checking every step. That is a very different skill from single-turn chat, and it is where Sonnet 5.5’s gains show up most.
In practice, four categories of workload benefit the most from this specific upgrade:
- Autonomous coding agents. Tools that write code, run tests, read the failure output, and fix the code again in a loop lean directly on the agentic coding gains the Terminal-Bench 4.0 score reflects.
- Long-document analysis and due diligence. The 1,000,000-token context window lets you load an entire contract set, codebase, or research corpus into a single call instead of chunking it through a retrieval layer first.
- High-volume customer support and ticket triage. Combining prompt caching on a shared knowledge base with the Message Batches API for non-urgent tickets keeps per-ticket cost low enough to automate first-pass triage economically.
- Internal developer tooling. Code review bots, changelog generators, and documentation assistants benefit from the same agentic reliability gains at a price point that makes running them on every pull request affordable.
If your workload is simple single-turn classification or short-form content generation, the practical difference between Sonnet 5 and Sonnet 5.5 will be smaller, and it may be worth testing a smaller, cheaper model first. The rest of this guide assumes you have a workload in one of the four categories above, or you are setting up infrastructure generically and want it to be ready for whichever of these use cases comes next.
Prerequisites: What You Need Before You Start
You do not need specialized hardware to call Claude Sonnet 5.5 since all inference runs on Anthropic’s servers, but you do need a handful of accounts and tools set up correctly before step one.
- An Anthropic Console account with billing enabled (console.claude.com), or an AWS, Google Cloud, or Azure account if you plan to call the model through one of those platforms instead
- Python 3.10 or newer, or Node.js 18 or newer, depending on which SDK you plan to use
- The official
anthropicPython package or@anthropic-ai/sdkTypeScript/JavaScript package, installed at the latest available version - A terminal with
curlavailable, for testing raw HTTP requests before wiring up SDK code - A code editor and, ideally, a secrets manager or
.envfile workflow so you never commit an API key to source control - If deploying through a cloud platform: an AWS account with Bedrock model access requested, a Google Cloud project with Vertex AI enabled, or an Azure subscription with AI Foundry access
Budget for the API itself matters too. Claude Sonnet 5.5 bills at $2 per million input tokens and $10 per million output tokens on the direct Anthropic API, identical to Sonnet 5’s standard pricing. A few test calls during setup will cost fractions of a cent, so there is no real financial barrier to working through every step in this guide.
Step 1: Create an Anthropic Console Account and Request API Access
Go to the Anthropic Console and sign up with a work or personal email. New accounts land in a Build tier with modest default rate limits, which is enough to complete every step in this tutorial. Once you are logged in, add a payment method under the Billing section, since the API will not process requests, even test ones, on an account with no billing configured. Anthropic’s own documentation on the Claude Sonnet 5.5 launch page confirms the model is available immediately to any account with standard API access, with no separate waitlist or gated rollout the way some frontier releases from other labs have required this year.
Step 2: Generate Your API Key
Inside the Console, open the API Keys page and create a new key. Name it something that identifies its purpose, for example sonnet-5-5-tutorial-dev, so you can revoke it independently later without breaking other integrations. Copy the key immediately since Anthropic only displays it once.
Store it as an environment variable rather than hardcoding it anywhere:
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"
On Windows PowerShell, use $env:ANTHROPIC_API_KEY = "sk-ant-api03-your-key-here" instead. For anything beyond a quick local test, put this in a .env file that is listed in .gitignore, or load it from a proper secrets manager such as AWS Secrets Manager, Google Secret Manager, or HashiCorp Vault.
Step 3: Install the Official SDK
Anthropic maintains first-party SDKs for Python and TypeScript/JavaScript, both open source on GitHub. Pick whichever matches your project.
Python
pip install -U anthropic
TypeScript / JavaScript
npm install @anthropic-ai/sdk
Both packages are actively maintained; check the Python SDK repository and the TypeScript SDK repository for the current release before you start, since Anthropic ships SDK updates frequently to support new model features. The PyPI package page lists every published version if you need to pin a specific one for reproducibility.
Step 4: Make Your First Claude Sonnet 5.5 API Call
With the key exported and the SDK installed, send a minimal request. The model identifier for the direct Anthropic API is claude-sonnet-5-5.
Python example
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain the difference between prompt caching and batch processing in two sentences."}
]
)
print(message.content[0].text)
Raw curl request
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": 1024,
"messages": [
{"role": "user", "content": "Explain the difference between prompt caching and batch processing in two sentences."}
]
}'
A successful response returns a JSON object with a content array, a stop_reason, and a usage block reporting input and output token counts. That usage block is where you will track cost per request once you move past testing.
Expected output
{
"id": "msg_01XampleId000000000000",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5-5",
"content": [
{
"type": "text",
"text": "Prompt caching stores a reusable prefix of your input so repeated context costs less on later calls. Batch processing groups many requests together for asynchronous processing at a lower per-token rate, trading immediacy for a discount."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 24,
"output_tokens": 48
}
}
Step 5: Understand the Claude Sonnet 5.5 Model ID and Context Limits
Anthropic’s own platform documentation lists claude-sonnet-5-5 as the current model string for the direct API, Vertex AI, and Azure AI Foundry alike, which keeps request bodies nearly identical across providers. Claude Sonnet 5.5 ships with a 1,000,000-token context window and a standard maximum output of 128,000 tokens per response. Anthropic’s model overview also documents an extended batch output mode capable of up to 300,000 output tokens through the Message Batches API, gated behind the output-300k-2026-03-24 beta header for workloads that genuinely need it, such as generating very long structured reports in a single pass.
The model’s training data has a reported knowledge cutoff around June 2026, according to Anthropic’s platform documentation. That is a meaningfully more recent cutoff than most models that were current just two or three release cycles ago, which matters if your use case depends on the model knowing about recent frameworks, libraries, or events.
Step 6: Enable Prompt Caching to Cut Repeated-Context Costs
If your application sends the same large system prompt, document, or codebase context on every call, for example a coding assistant that resends a full file on each turn, prompt caching is the single highest-leverage cost optimization available. Anthropic states plainly that “Sonnet 5.5 is priced at $2 per million input tokens and $10 per million output tokens, with up to 90% cost savings with prompt caching and 50% cost savings with batch processing.” To use it, mark the reusable portion of your request with a cache_control block:
message = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
system=[
{
"type": "text",
"text": large_codebase_context,
"cache_control": {"type": "ephemeral"}
}
],
messages=[
{"role": "user", "content": "Review this function for bugs."}
]
)
The first call writes the cache and costs more per token than a normal input ($2.50 per million tokens for a 5-minute cache, or $4.00 per million tokens for a 1-hour cache, according to Anthropic’s pricing documentation), but every subsequent call that hits the same cached prefix within the time-to-live window only pays $0.20 per million tokens for that portion. For a chatbot or coding tool that reuses the same large context across many turns, that is the difference between a usable cost structure and one that scales badly. Our dedicated LLM prompt caching setup guide covers cache-hit strategy in more depth if you are optimizing an existing high-volume integration rather than starting from scratch.
Step 7: Use the Message Batches API for Bulk, Non-Urgent Work
Anthropic’s platform documentation confirms that “Claude Sonnet 5.5 has the same prices as Claude Sonnet 5, including prompt caching and batch processing rates,” and batch processing itself cuts standard token pricing by 50% in exchange for asynchronous, not-instant delivery. This is the right tool when you need to process thousands of records, for example summarizing a backlog of support tickets or classifying a dataset, and you do not need the response within seconds.
batch = client.messages.batches.create(
requests=[
{
"custom_id": f"ticket-{i}",
"params": {
"model": "claude-sonnet-5-5",
"max_tokens": 512,
"messages": [{"role": "user", "content": ticket_text}]
}
}
for i, ticket_text in enumerate(support_tickets)
]
)
print(batch.id, batch.processing_status)
Poll client.messages.batches.retrieve(batch.id) until processing_status reports ended, then stream the results. Batches typically complete well within 24 hours, and Anthropic does not charge for requests that fail validation before processing starts.
Step 8: Add Tool Use and Function Calling
Claude Sonnet 5.5 supports the same tool-use schema as prior Claude generations, letting you define functions the model can request to call mid-conversation. This is the backbone of any agentic workflow, from a coding assistant that runs tests to a support bot that looks up order status in a database.
tools = [
{
"name": "get_order_status",
"description": "Look up the shipping status of a customer order by order ID.",
"input_schema": {
"type": "object",
"properties": {
"order_id": {"type": "string", "description": "The order ID to look up."}
},
"required": ["order_id"]
}
}
]
response = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "Where is order 48213?"}]
)
for block in response.content:
if block.type == "tool_use":
print("Model wants to call:", block.name, block.input)
When stop_reason comes back as tool_use, run the actual function in your own code, then send the result back in a follow-up message with role user and a tool_result content block referencing the original tool call ID. The model picks up the conversation from there.
Step 9: Stream Responses for Real-Time Interfaces
A standard request waits for the full response before returning anything, which is fine for a batch script but produces a noticeably sluggish experience in a chat interface, since Claude Sonnet 5.5 can take several seconds to finish a longer answer. For anything user-facing, stream the response instead so text appears token by token as it is generated.
with client.messages.stream(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a short changelog entry for a caching bugfix."}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
final_message = stream.get_final_message()
print("nnTokens used:", final_message.usage.output_tokens)
On the raw HTTP side, add "stream": true to the request body and parse the response as a series of server-sent events rather than a single JSON payload. Both SDKs handle the event parsing for you, which is the main reason to prefer the SDK over raw curl once you move past initial testing.
Step 10: Deploy Through Amazon Bedrock Instead of the Direct API
Teams already standardized on AWS often prefer to call Claude through Bedrock rather than managing a separate Anthropic billing relationship. Amazon’s Bedrock model card for Claude Sonnet 5.5 lists the model under the identifier anthropic.claude-sonnet-5-5, with regional inference profile variants such as us.anthropic.claude-sonnet-5-5, eu.anthropic.claude-sonnet-5-5, and a global.anthropic.claude-sonnet-5-5 profile for workloads that do not need to pin to a specific region.
Before calling it, request model access in the Bedrock console under Model Access, since Anthropic models on Bedrock require an explicit access grant even on accounts with billing already configured. Once access is approved, a Python call through boto3 looks like this:
import boto3
import json
bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")
response = bedrock.invoke_model(
modelId="us.anthropic.claude-sonnet-5-5",
body=json.dumps({
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Summarize this quarter's error logs in three bullet points."}
]
})
)
result = json.loads(response["body"].read())
print(result["content"][0]["text"])
Billing on Bedrock follows AWS’s own metering rather than a separate Anthropic invoice, which is often the deciding factor for enterprise teams that need everything inside one cloud bill for procurement reasons.
Step 11: Deploy Through Vertex AI or Azure AI Foundry
Google Cloud and Microsoft Azure customers get the same claude-sonnet-5-5 model identifier through Vertex AI’s Model Garden and Azure AI Foundry’s model catalog, respectively, according to Anthropic’s own platform documentation. The request and response shapes mirror the direct Anthropic API closely enough that most of the SDK code from Step 4 needs only an authentication and endpoint change to run on either platform. Vertex AI requires enabling the Vertex AI API on your Google Cloud project and requesting access to the Claude model family inside Model Garden before your first call will succeed; Azure AI Foundry requires deploying the model into a project within the Foundry portal first, which generates the specific endpoint URL your code will call.
If your organization is multi-cloud by policy rather than by choice, this cross-platform availability is one of the more practical reasons to standardize on Claude Sonnet 5.5 rather than a model that is only available through a single vendor’s API.
Step 12: Monitor Usage, Costs, and Rate Limits
Every Claude Sonnet 5.5 response includes a usage object with input_tokens and output_tokens counts, and cached requests additionally report cache_creation_input_tokens and cache_read_input_tokens so you can verify caching is actually firing rather than silently falling back to full-price input. Log these fields on every call, even in a test environment, so you catch pricing surprises before they show up on a monthly invoice.
The Anthropic Console’s Usage dashboard aggregates this same data account-wide and breaks it down by model and by API key, which is the fastest way to confirm a specific integration is behaving as expected. New accounts start in the Build tier with rate limits that scale up automatically as your account accumulates spend history; if you are planning a launch that will spike traffic suddenly, request a rate limit increase through the Console ahead of time rather than discovering the ceiling during a production incident.
Step 13: Pin a Model Version for Production Stability
The claude-sonnet-5-5 alias always points to Anthropic’s current recommended snapshot of the model, which is convenient during development but risky in production, since Anthropic can update what that alias resolves to without warning your application. Check Anthropic’s release notes for a dated snapshot identifier before you ship, and reference that dated string explicitly in production code instead of the floating alias. This single habit is what separates teams that get blindsided by a silent model update from teams that control exactly when they adopt a new version.
Step 14: Migrate Existing Sonnet 5 Code
For most existing integrations, migrating from Claude Sonnet 5 to Sonnet 5.5 is a one-line change: replace the model string with claude-sonnet-5-5 and redeploy. Anthropic has kept the request schema, tool-use format, and pricing structure unchanged between the two versions, which is precisely the point of a minor-version release rather than a major one. The practical migration checklist is short:
- Update the model string everywhere it appears, including in any configuration files, environment variables, or feature flags that select a model by name
- Re-run your evaluation suite, if you have one, before fully cutting over, since even a same-family upgrade can shift output tone or length slightly
- Check whether your prompts were tuned around Sonnet 5’s specific weaknesses; some workaround instructions baked into older prompts may no longer be necessary and can be removed
- Confirm your logging still captures
cache_creation_input_tokensandcache_read_input_tokenscorrectly, since cache behavior carries over unchanged but is worth re-verifying after any model swap
Claude Sonnet 5.5 Pricing at a Glance
| Usage type | Price |
|---|---|
| Input tokens | $2.00 per million tokens |
| Output tokens | $10.00 per million tokens |
| Prompt cache write, 5-minute TTL | $2.50 per million tokens |
| Prompt cache write, 1-hour TTL | $4.00 per million tokens |
| Prompt cache read | $0.20 per million tokens |
| Batch processing (input and output) | 50% off standard rates |
These figures come directly from Anthropic’s pricing documentation and its official Claude Sonnet model page, and they are unchanged from Claude Sonnet 5’s standard pricing, which itself became the standard rate once Sonnet 5’s introductory pricing window closed on August 31, 2026.
Worked example: pricing a code review bot
Take the pull-request review bot built later in this guide. Assume a 20,000-token repository context cached once per day with a 1-hour time-to-live, reviewed against 50 pull requests that day, each diff averaging 2,000 input tokens and each review averaging 800 output tokens.
- Cache write (once): 20,000 tokens x $4.00 / million = $0.08
- Cache reads (50 reviews): 50 x 20,000 tokens x $0.20 / million = $0.20
- Diff input (50 reviews): 50 x 2,000 tokens x $2.00 / million = $0.20
- Review output (50 reviews): 50 x 800 tokens x $10.00 / million = $0.40
That totals roughly $0.88 for an entire day of automated review across 50 pull requests, compared to an estimated $1.68 if caching were skipped and the full repository context were resent on every single call. The saving grows with review volume and with how large the cached context is, which is exactly why caching matters more as a Claude Sonnet 5.5 integration scales rather than during initial testing.
Claude Sonnet 5.5 Model Identifiers by Platform
| Platform | Model identifier |
|---|---|
| Anthropic API (direct) | claude-sonnet-5-5 |
| Amazon Bedrock | anthropic.claude-sonnet-5-5 |
| Amazon Bedrock, US regional profile | us.anthropic.claude-sonnet-5-5 |
| Amazon Bedrock, EU regional profile | eu.anthropic.claude-sonnet-5-5 |
| Amazon Bedrock, global profile | global.anthropic.claude-sonnet-5-5 |
| Google Cloud Vertex AI | claude-sonnet-5-5 |
| Microsoft Azure AI Foundry | claude-sonnet-5-5 |
Claude Sonnet 5.5 vs Claude Sonnet 5: Benchmark Comparison
| Benchmark | Claude Sonnet 5.5 | Claude Sonnet 5 |
|---|---|---|
| Terminal-Bench 4.0 | 70.6% | 10.3% |
| FrontierCode 1.1 (Max effort) | 46.2% | Not published at this configuration |
| FrontierCode 1.1 (Xhigh effort) | 52.1% | Not published at this configuration |
| CursorBench 4.0 | 55.5% | Not published at this configuration |
| GDPval-AA | Within 2 points of Claude Opus 5.5 | Not published at this configuration |
| Standard pricing | $2 / $10 per million tokens | $2 / $10 per million tokens |
The Terminal-Bench 4.0 jump is the headline figure Anthropic leads with, and it reflects the benchmark’s focus on multi-step, agentic command-line tasks rather than single-turn question answering. For teams evaluating whether the upgrade justifies the (minimal) migration effort, the fact that price stayed flat while this specific benchmark more than sextupled makes the decision close to automatic.
Common Pitfalls When Setting Up Claude Sonnet 5.5
Most setup failures trace back to a handful of repeat mistakes, most of which have nothing to do with the model itself.
- Forgetting to enable billing before the first call. A Console account with no payment method attached will reject every request with an authorization error that looks like a key problem rather than a billing one.
- Using the floating model alias in production. Code that references
claude-sonnet-5-5without a dated snapshot can behave differently after Anthropic updates what that alias points to, with no deploy on your end to explain the change. - Assuming cache_control is free the first time. The first request against a new cache prefix costs more per token than standard input, not less; the discount only applies to later calls that hit the cache.
- Requesting Bedrock access and calling the model in the same session. Bedrock model access approval is not always instant, and calling an unapproved model ID returns an access-denied error that is easy to mistake for a credentials problem.
- Mismatching the
anthropic_versionheader on Bedrock. Bedrock requiresbedrock-2023-05-31in the request body rather than theanthropic-versionHTTP header used by the direct API, and mixing the two conventions produces a validation error. - Not checking SDK version before using a new feature. Extended batch output and some tool-use schema updates require a reasonably current SDK release; an old pinned version can silently ignore new parameters instead of erroring clearly.
Troubleshooting Claude Sonnet 5.5 API Errors
These are the errors developers most commonly hit while integrating Claude Sonnet 5.5, along with the fix for each.
- 401 authentication_error: The API key is missing, malformed, or was revoked. Confirm
ANTHROPIC_API_KEYis actually exported in the shell or process running your code, not just set in a terminal tab you later closed. - 403 permission_error on Bedrock or Vertex AI: Model access has not been granted yet for your account or project. Check the Model Access page in Bedrock, or Model Garden access in Vertex AI, and wait for approval before retrying.
- 429 rate_limit_error: You have exceeded your account’s current requests-per-minute or tokens-per-minute limit. Implement exponential backoff, and if this happens consistently under normal load, request a limit increase in the Console.
- 400 invalid_request_error referencing max_tokens: The requested
max_tokensvalue exceeds what the model and request configuration allow. Standard output caps at 128,000 tokens; anything beyond that requires the extended batch output beta header. - Cache not reducing cost: Check
cache_read_input_tokensin the usage block. If it is zero on a call you expected to hit the cache, the cached prefix likely changed between calls, even by a single character, which invalidates the match. - Tool use loop never resolves: If the model keeps requesting the same tool call, check that your
tool_resultblock references the correcttool_use_idand that the result content is formatted as the model expects, typically a string or JSON-serializable block. - Batch stuck in “in_progress” far longer than expected: Very large batches can take longer to clear, but if a batch has not progressed in several hours, check the per-request error field in the batch results rather than assuming the whole batch is still processing.
- Different output between direct API and Bedrock/Vertex/Azure for the same prompt: Minor differences in default sampling parameters or system prompt handling between platforms can produce slightly different phrasing even with an identical prompt. This is expected and not a bug; pin
temperatureand other sampling parameters explicitly if you need tighter consistency across platforms.
Advanced Tips: Getting More Out of the 1M-Token Context
A million-token context window changes how you should architect a retrieval pipeline. For many use cases that previously required a vector database purely to fit relevant context into a smaller window, it is now worth testing whether you can simply paste the full document set directly into the prompt and skip retrieval entirely, since Claude Sonnet 5.5 can hold an entire mid-size codebase or a long document collection in context at once. Combine this with prompt caching on the large static portion of that context, and repeated queries against the same document set become dramatically cheaper than re-sending everything on every call.
For workloads that need more than the standard 128,000-token output ceiling, for example generating a very long structured report or a large batch of generated code files in one response, test the extended batch output mode behind the output-300k-2026-03-24 beta header inside the Message Batches API rather than trying to force a single synchronous call past its normal limit. And when migrating a complex multi-step agent prompt from Sonnet 5, re-test it rather than assuming identical behavior; Anthropic’s benchmark data shows Sonnet 5.5 needs meaningfully fewer steps to complete the same agentic task, which can change how your orchestration logic should structure retries and step limits.
It is also worth separating cache time-to-live choices by workload shape rather than defaulting to the shorter 5-minute option everywhere. A support bot handling a steady stream of tickets throughout a business day benefits from the 1-hour cache, since the write-cost premium gets amortized across far more cache reads before expiry. A low-traffic internal tool that gets used in short bursts, on the other hand, may never generate enough reads within an hour to justify the higher write cost, and the 5-minute cache will be cheaper in practice. Track cache_read_input_tokens against cache_creation_input_tokens for a week of real traffic before committing to one TTL over the other; the right answer depends on your actual request pattern, not on a general rule.
Finally, if you are building anything agentic, cap the number of tool-use round trips a single request can take before forcing a final answer. Even a model with strong agentic benchmark performance can occasionally loop longer than expected on an ambiguous tool result, and a hard step limit protects both your latency budget and your output-token bill.
Complete Working Project: A Pull-Request Review Bot
To tie every piece above together, here is a complete, runnable script that uses Claude Sonnet 5.5 to review a code diff, using prompt caching for the repo context and tool use to fetch the diff in the first place.
import subprocess
import anthropic
client = anthropic.Anthropic()
def get_git_diff():
result = subprocess.run(
["git", "diff", "--staged"],
capture_output=True, text=True
)
return result.stdout
def review_pull_request(repo_context, diff_text):
response = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=2048,
system=[
{
"type": "text",
"text": f"You are a senior code reviewer. Repository context:n{repo_context}",
"cache_control": {"type": "ephemeral"}
}
],
messages=[
{
"role": "user",
"content": f"Review this diff for bugs, security issues, and style problems:nn{diff_text}"
}
]
)
return response.content[0].text, response.usage
if __name__ == "__main__":
with open("README.md") as f:
repo_context = f.read()
diff = get_git_diff()
if not diff.strip():
print("No staged changes to review.")
else:
review, usage = review_pull_request(repo_context, diff)
print(review)
print(f"n--- Tokens used: {usage.input_tokens} in / {usage.output_tokens} out ---")
Run it with python review_bot.py after staging a change with git add. The first run pays the cache-write rate on the README context; every subsequent review against the same repository context pays the much cheaper cache-read rate instead. Wrap this in a pre-commit hook or a CI step that comments on a pull request, and you have a working, cost-aware review assistant built entirely on the pieces covered in this tutorial.
Should You Use Claude Sonnet 5.5 or Wait for Claude Opus 5.5?
Claude Opus 5.5 remains Anthropic’s top-of-line model and still leads Sonnet 5.5 on the hardest reasoning tasks, but Anthropic’s own data puts Sonnet 5.5 within two points of Opus 5.5 on GDPval-AA, a knowledge-work benchmark meant to track real economic value rather than synthetic puzzle-solving. For the large majority of production use cases, coding assistance, document analysis, customer support automation, internal tooling, Sonnet 5.5’s price-to-capability ratio makes it the more sensible default, with Opus 5.5 reserved for the specific subset of tasks where the gap actually matters. Teams running cost-sensitive, high-volume workloads should start with Sonnet 5.5 and only escalate individual requests to Opus 5.5 when a task genuinely requires it.
A practical pattern worth building into any agentic system is routing by task difficulty rather than picking one model for an entire application. Run a cheap classification pass, or simply inspect task metadata you already have, to flag the subset of requests that are genuinely high-stakes or unusually complex, and send only those through to Opus 5.5 while everything else stays on Sonnet 5.5. Because both models share the same request schema and tool-use format, this kind of routing logic is a small conditional in your application code rather than a structural rewrite, and it lets you capture most of Opus-level quality on the requests that need it without paying flagship pricing on the 80 to 90% of traffic that does not.
If you are also weighing OpenAI’s and Google’s latest models for the same workload, our Claude Fable 5.1 API setup guide and the best AI models 2026 hub round up pricing and setup steps across the current model landscape so you are not re-deriving the same research for every provider.
Frequently Asked Questions
What is the exact model ID for Claude Sonnet 5.5?
Use claude-sonnet-5-5 on the direct Anthropic API, Google Cloud Vertex AI, and Microsoft Azure AI Foundry. On Amazon Bedrock, use anthropic.claude-sonnet-5-5, or a regional variant such as us.anthropic.claude-sonnet-5-5 if you need to pin to a specific region.
How much does the Claude Sonnet 5.5 API cost?
Standard pricing is $2 per million input tokens and $10 per million output tokens, identical to Claude Sonnet 5. Prompt caching can cut effective input cost by up to 90% on repeated context, and batch processing cuts standard rates by 50% for asynchronous workloads.
Is Claude Sonnet 5.5 free to try?
There is no permanently free tier for the API, but new Anthropic Console accounts can add a small amount of credit to test the model, and a handful of test calls in this tutorial will cost well under a dollar total given the per-token pricing above.
How big is the Claude Sonnet 5.5 context window?
It supports a 1,000,000-token context window with a standard maximum output of 128,000 tokens per response, plus an extended batch output mode capable of up to 300,000 output tokens through the Message Batches API using a beta header.
Does migrating from Claude Sonnet 5 require code changes?
In most cases no, beyond updating the model string to claude-sonnet-5-5. Anthropic kept the request schema, tool-use format, and pricing structure unchanged between the two versions, so the same integration code generally works against either model.
Can I use Claude Sonnet 5.5 without an Anthropic account, through AWS or Google Cloud instead?
Yes. The model is available through Amazon Bedrock, Google Cloud Vertex AI, and Microsoft Azure AI Foundry, each with its own access request process and billing handled inside that cloud platform rather than through a separate Anthropic invoice.
What is the knowledge cutoff for Claude Sonnet 5.5?
Anthropic’s platform documentation reports a training data cutoff around June 2026.
Which official SDKs support Claude Sonnet 5.5?
The official anthropic Python package and @anthropic-ai/sdk TypeScript/JavaScript package both support the model. Install the latest version of either with pip install -U anthropic or npm install @anthropic-ai/sdk before following the steps in this guide.