Claude Opus 5.5 API Setup: 13 Steps, $4/$20 per 1M [2026]

Anthropic shipped Claude Opus 5.5 on September 22, 2026, and the pitch is blunt: it matches Claude Fable 5.1 on most real-world work while costing 20% less to run than its predecessor, Claude Opus 5. For developers who’ve been paying $5 per million input tokens and $25 per million output tokens, that’s not a rounding error. It’s a reason to rebuild your cost model. This tutorial walks through every step of setting up the Claude Opus 5.5 API in a real project, from creating an API key to shipping a working tool that actually uses the model’s 1-million-token context window.

By the end, you’ll have a command-line application that ingests an entire codebase or log archive, summarizes it with Claude Opus 5.5, caches the expensive parts of the prompt, and batches overnight jobs at half price. We’ll also cover the eight most common errors developers hit when switching models, five pitfalls that quietly double your bill, and how Opus 5.5 stacks up against Claude Sonnet 5.5, Claude Opus 5, and Claude Fable 5.1 so you pick the right model for the job instead of defaulting to the most expensive one.

Google · Preferred Sources

Don't miss new tech stories on Google

Add Tech Insider once in the Google app and our stories appear in your news suggestions.

Add Now

What Is Claude Opus 5.5, and Why It Changes the API Math

Claude Opus 5.5 is the first model in Anthropic’s new Claude 5.5 family, aimed at long-running agentic coding and knowledge work rather than quick chat replies. The model ID is claude-opus-5-5, a fixed string with no date suffix, which matters because it means you don’t need to chase a new snapshot name every quarter the way you did with earlier Opus releases. Anthropic says Opus 5.5 performs at roughly the level of Claude Fable 5.1 on most tasks while running at 40% lower cost, and it leads Anthropic’s own benchmark table on SWE-bench Pro at 89.9%, ahead of Claude Sonnet 5.5 (81.3%), Claude Fable 5.1 (81.2%), and the older Claude Opus 5 (79.2%), according to BenchLM’s October 2026 SWE-bench Pro leaderboard.

Three changes make the Claude Opus 5.5 API worth a dedicated setup guide instead of a one-line model-string swap. First, pricing dropped to $4 per million input tokens and $20 per million output tokens, down from $5/$25 for Opus 5, according to Anthropic’s Claude Platform release notes. Second, the model runs with a 1-million-token context window and up to 128,000 output tokens by default, no special header required. Third, Opus 5.5 uses always-on adaptive thinking instead of an opt-in extended-thinking flag, so the model decides how much reasoning effort a request needs, defaulting to a medium effort level unless you tell it otherwise.

None of that means Opus 5.5 is the right model for every call. If you’re already happy with Claude Sonnet 5.5’s API setup for well-scoped tasks like bug fixes or document drafting, keep using it. Opus 5.5 earns its keep on multi-hour agentic jobs, large-codebase refactors, and anything that benefits from genuinely long context rather than a clever summary of it.

It also matters that Opus 5.5 arrived alongside a usage-limit change on the consumer side. Anthropic raised five-hour usage limits on Pro, Max, Team, and seat-based Enterprise plans at the same time it cut API pricing, a signal that the company expects developers to run more, not fewer, Opus-class calls now that the per-token cost has dropped. If your team has been rationing Opus usage to control spend, this release is the point to revisit that budget rather than keep the old restrictions in place out of habit.

Prerequisites and Requirements

You don’t need much to follow along with this Claude Opus 5.5 API setup, but get the versions right before you start, because the Claude Python SDK moves fast and older releases don’t expose every Opus 5.5 parameter.

  • An Anthropic Console account at console.anthropic.com with billing enabled (a credit card or prepaid credit balance)
  • Python 3.9 or later, or Node.js 18 or later if you prefer TypeScript
  • The official anthropic Python package, version 0.45.0 or later (run pip show anthropic to check)
  • A terminal with curl for quick API tests before you write any code
  • Roughly 90 minutes for the full walkthrough, including the working project at the end
  • Optional: an AWS, Google Cloud, or Microsoft Azure account if you plan to deploy through Bedrock, Vertex AI, or Foundry instead of calling Anthropic’s API directly

One thing worth deciding up front: how you’ll track spend. Opus 5.5 is cheaper than Opus 5, but a 1-million-token context window makes it easy to accidentally send a huge prompt and get an unpleasant invoice. We’ll set spend limits in Step 13, but keep it in mind while you’re testing.

Steps 1-4: Account, API Key, SDK Install, and Your First Call

Step 1: Create Your Anthropic Console Account and Generate an API Key

Sign in at the Anthropic Console, add a payment method under Billing, and open the API Keys section. Click “Create Key,” name it something you’ll recognize later (for example, opus-5-5-digest-tool), and copy the value immediately. Anthropic only shows it once. Store it as an environment variable rather than hardcoding it anywhere:

export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"

Add that line to your shell profile (.zshrc, .bashrc, or equivalent) so it persists across terminal sessions, and never commit it to a repository. If you’ve ever pushed a key by accident, rotate it from the same Console page before moving on.

Step 2: Confirm Billing Tier and Initial Rate Limits

New accounts start on usage Tier 1, which caps requests per minute and tokens per minute at conservative levels while Anthropic verifies payment history. Tier limits increase automatically as your account accrues spend and age, and you can check your current tier and exact numbers on the Console’s Limits page. The retrieved documentation doesn’t publish a single universal Tier 1 number for Opus 5.5 specifically, since limits are account-specific, so check your own dashboard rather than assuming a figure from a blog post.

What you can plan around is the general shape of the tier system: Anthropic ties higher tiers to cumulative spend and account age, not to a one-time application or approval form. That means the fastest route to a higher ceiling is simply running real traffic consistently rather than firing one large test batch and hoping it bumps you up overnight. If you know you’ll need high throughput on day one, for example to process a backlog of thousands of documents, it’s worth spreading that first batch across a few days instead of one, so you don’t bounce off a rate limit the moment you need it least.

Step 3: Install the Official SDK

Install the Python SDK in a virtual environment so it doesn’t collide with other projects:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade anthropic

If you’re working in Node.js instead, swap in npm install @anthropic-ai/sdk. Both SDKs expose the same model parameters, so the rest of this guide applies either way, with syntax adjusted for your language.

Step 4: Make Your First Call to Claude Opus 5.5

With the key exported and the SDK installed, send a minimal request to confirm everything is wired up correctly:

import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "In two sentences, what changed in Claude Opus 5.5?"}
    ]
)

print(message.content[0].text)
print("Input tokens:", message.usage.input_tokens)
print("Output tokens:", message.usage.output_tokens)

Running that script should return a short answer plus token counts in the terminal, something like:

Claude Opus 5.5 dropped pricing to $4/$20 per million tokens, cut 20% from
Opus 5's $5/$25 rate, while adding a 1-million-token context window and
always-on adaptive thinking by default.
Input tokens: 16
Output tokens: 41

If you see an authentication error here, jump ahead to the troubleshooting section before continuing. There’s no point debugging prompt caching on a connection that doesn’t work yet.

Step 5: Understand Claude Opus 5.5 Pricing Before You Build Anything

Pricing drives every architecture decision you’ll make with this model, so get the numbers straight before writing production code. Claude Opus 5.5 bills at $4 per million input tokens and $20 per million output tokens for standard requests, a 20% cut from Claude Opus 5’s $5/$25 rate, according to Anthropic’s own model overview documentation. Prompt caching and batch processing both apply additional discounts on top of that base rate, which we’ll use directly in Steps 8 and 9.

Pricing TierInput (per 1M tokens)Output (per 1M tokens)Notes
Standard$4.00$20.00Base rate, no caching or batching
Prompt cache write (5-minute)$5.00—One-time cost to cache a prompt segment
Prompt cache write (1-hour)$8.00—Longer TTL for repeat sessions
Prompt cache read$0.20—5% of standard input price, a 95% discount
Batch API$2.00$10.00Flat 50% discount, asynchronous processing

A quick worked example: if you’re sending a 50,000-token codebase as context on every call and only the user’s question changes, the first call costs roughly $0.20 for that context segment at standard input pricing. Cache it, and every subsequent call against the same context costs about $0.01 for the cached portion instead, a difference that compounds fast once you’re running hundreds of queries against the same repository in a single afternoon.

Step 6: Put the 1-Million-Token Context Window to Work

Claude Opus 5.5 ships with a 1-million-token context window enabled by default and a maximum output of 128,000 tokens per response, per Anthropic’s release notes. That’s enough to load a mid-sized codebase, a full legal contract set, or months of support tickets into a single call without chunking. The catch is that a 1-million-token prompt at $4 per million tokens still costs about $4 just to send once, so this capability is most valuable when you reuse that context repeatedly, which is exactly what prompt caching is for.

Here’s how to load a large file set into a single request:

import os
import anthropic

client = anthropic.Anthropic()

def load_codebase(directory, extensions=(".py", ".js", ".md")):
    chunks = []
    for root, _, files in os.walk(directory):
        for name in files:
            if name.endswith(extensions):
                path = os.path.join(root, name)
                with open(path, "r", errors="ignore") as f:
                    chunks.append(f"--- {path} ---\n{f.read()}")
    return "\n\n".join(chunks)

codebase_text = load_codebase("./my-project")

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=4096,
    messages=[
        {"role": "user", "content": f"Here is a full codebase:\n\n{codebase_text}\n\nSummarize the architecture in 10 bullet points."}
    ]
)

print(response.content[0].text)

For anything beyond a quick test, don’t send raw context on every call. Structure the request so the large, unchanging part sits first and gets cached, which is exactly what Step 8 covers.

Step 7: Configure Adaptive Thinking Effort Levels

Unlike earlier Claude models that required an explicit extended-thinking flag, Opus 5.5 uses always-on adaptive thinking. The model decides internally how much reasoning to apply, and Anthropic reports it defaults to medium effort. At that default setting, Anthropic says Opus 5.5 scores 52.5% on its internal agentic benchmark, ahead of Claude Fable 5.1’s 51.8% at maximum effort and Claude Opus 5’s 46.6% at maximum effort, according to Anthropic’s Claude Opus product page. That’s a meaningful detail: Opus 5.5 at its default setting already beats older models running at their hardest setting.

For latency-sensitive applications like a chat interface, you can bias toward speed by keeping prompts tightly scoped and avoiding unnecessary context. For batch research or refactor jobs where correctness matters more than response time, give the model room to reason by increasing max_tokens and letting it work through the problem rather than truncating output early. Anthropic’s documentation doesn’t currently expose a manual per-effort token budget override for Opus 5.5 the way older thinking-mode flags did, so the practical lever you control is prompt design and output budget, not a hidden reasoning-depth parameter.

Step 8: Cut Costs by Up to 95% With Prompt Caching

Prompt caching is the single biggest cost lever available on Opus 5.5. Mark a block of your prompt as cacheable, and Anthropic stores it for either 5 minutes or 1 hour depending on which TTL you request. Every subsequent call that reuses that exact block pays the $0.20 cache-read rate instead of the $4 standard input rate, a 95% discount. For a deeper walkthrough of caching strategy across providers, see our LLM prompt caching setup guide; here’s the Opus 5.5-specific implementation:

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=2048,
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": codebase_text,
                    "cache_control": {"type": "ephemeral", "ttl": "1h"}
                },
                {
                    "type": "text",
                    "text": "What security issues do you see in the authentication module?"
                }
            ]
        }
    ]
)

print("Cache creation tokens:", response.usage.cache_creation_input_tokens)
print("Cache read tokens:", response.usage.cache_read_input_tokens)

Run that same request five more times with different follow-up questions appended after the cached block, and only the small, variable part of the prompt bills at full price each time. In practice, teams running repeated queries against the same large document or repository report their effective cost per query dropping by an order of magnitude once caching is wired in correctly.

Step 9: Batch Large Jobs at 50% Off

If your workload doesn’t need an answer in real time, the Batch API cuts both input and output pricing in half, bringing Opus 5.5 down to an effective $2 per million input tokens and $10 per million output tokens. That’s the right tool for overnight jobs like summarizing a week of support tickets, re-indexing documentation, or running a bulk code review across every file in a monorepo.

import anthropic

client = anthropic.Anthropic()

batch = client.messages.batches.create(
    requests=[
        {
            "custom_id": f"file-{i}",
            "params": {
                "model": "claude-opus-5-5",
                "max_tokens": 1024,
                "messages": [{"role": "user", "content": f"Review this file for bugs:\n\n{file_text}"}]
            }
        }
        for i, file_text in enumerate(file_contents)
    ]
)

print("Batch ID:", batch.id)
print("Status:", batch.processing_status)

Poll client.messages.batches.retrieve(batch.id) until processing_status reads ended, then pull results from the batch’s results URL. Batches typically complete within hours, not minutes, so this pattern fits scheduled jobs far better than user-facing requests.

Step 10: Deploy Through AWS Bedrock, Google Cloud, or Microsoft Foundry

If your company already routes AI spend through a specific cloud vendor for procurement or compliance reasons, Opus 5.5 is available on all three major platforms with slightly different model identifiers. On Amazon Bedrock, the native model ID is anthropic.claude-opus-5-5, with regional variants like us.anthropic.claude-opus-5-5, eu.anthropic.claude-opus-5-5, and a global.anthropic.claude-opus-5-5 routing option, according to AWS’s Bedrock model card documentation. Microsoft Foundry uses the simpler claude-opus-5-5 identifier, matching Anthropic’s own API.

import boto3
import json

bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")

response = bedrock.invoke_model(
    modelId="us.anthropic.claude-opus-5-5",
    body=json.dumps({
        "anthropic_version": "bedrock-2023-05-31",
        "max_tokens": 1024,
        "messages": [{"role": "user", "content": "Summarize this quarter's error logs."}]
    })
)

result = json.loads(response["body"].read())
print(result["content"][0]["text"])

One important detail: AWS bills model usage separately from Bedrock itself, so Opus 5.5 charges appear under the model provider line in AWS Cost Explorer, not under a generic Bedrock line item. If your finance team is auditing cloud spend, point them there directly instead of letting them search for “Anthropic” in the main billing dashboard.

Steps 11-12: Build a Complete Project — A Long-Context Repo Digest Tool

Now put all of the above together into something you’d actually use. We’re building repo-digest, a command-line tool that loads an entire codebase, caches it, lets you ask unlimited follow-up questions against that cached context for the next hour, and falls back to the Batch API if you point it at a folder of files to review in bulk instead of a single interactive session.

Step 11: Write the Core Digest Script

# repo_digest.py
import os
import sys
import anthropic

MODEL = "claude-opus-5-5"
MAX_CONTEXT_CHARS = 3_000_000  # roughly 750K tokens, safely under the 1M limit

client = anthropic.Anthropic()

def load_codebase(directory, extensions=(".py", ".js", ".ts", ".md", ".go")):
    chunks = []
    total_chars = 0
    for root, _, files in os.walk(directory):
        if "node_modules" in root or ".git" in root:
            continue
        for name in files:
            if name.endswith(extensions):
                path = os.path.join(root, name)
                try:
                    with open(path, "r", errors="ignore") as f:
                        text = f.read()
                except OSError:
                    continue
                if total_chars + len(text) > MAX_CONTEXT_CHARS:
                    print(f"Warning: truncating at {path}, context limit reached")
                    return "\n\n".join(chunks)
                chunks.append(f"--- {path} ---\n{text}")
                total_chars += len(text)
    return "\n\n".join(chunks)

def ask(codebase_text, question, ttl="1h"):
    response = client.messages.create(
        model=MODEL,
        max_tokens=4096,
        messages=[{
            "role": "user",
            "content": [
                {"type": "text", "text": codebase_text, "cache_control": {"type": "ephemeral", "ttl": ttl}},
                {"type": "text", "text": question}
            ]
        }]
    )
    return response.content[0].text, response.usage

if __name__ == "__main__":
    directory = sys.argv[1]
    question = sys.argv[2]
    codebase = load_codebase(directory)
    answer, usage = ask(codebase, question)
    print(answer)
    print(f"\n[cache_write={usage.cache_creation_input_tokens} cache_read={usage.cache_read_input_tokens} output={usage.output_tokens}]")

Run it with python repo_digest.py ./my-project "What's the biggest architectural risk in this codebase?". The first run pays the cache-write price for your full codebase; every follow-up question you ask within the hour against the same directory reads from cache at $0.20 per million tokens instead of $4. A first run against a mid-sized repository looks something like this in your terminal:

The biggest architectural risk is the shared database connection pool in
db/pool.py, which isn't thread-safe but is imported directly by four
background workers in workers/. Under concurrent load this will eventually
produce connection leaks rather than a clean error, making it hard to
diagnose in production. Recommend wrapping access in a queue or moving to
a connection-per-worker model.

[cache_write=187420 cache_read=0 output=612]

Ask a second question against the same directory a few minutes later, and the usage line flips: cache_write=0 cache_read=187420 output=..., confirming you just paid $0.20 per million tokens for the context instead of $4. That swing from write to read is the entire value proposition of this pattern, and it’s worth watching those two numbers directly in your logs rather than trusting that caching is working silently in the background.

Step 12: Add a Batch Mode for Bulk File Review

# batch_review.py
import glob
import anthropic

client = anthropic.Anthropic()

def submit_batch(file_pattern, question="Review this file for bugs and style issues."):
    files = glob.glob(file_pattern, recursive=True)
    requests = []
    for i, path in enumerate(files):
        with open(path, "r", errors="ignore") as f:
            content = f.read()
        requests.append({
            "custom_id": f"{i}-{path}",
            "params": {
                "model": "claude-opus-5-5",
                "max_tokens": 1024,
                "messages": [{"role": "user", "content": f"{question}\n\nFile: {path}\n\n{content}"}]
            }
        })
    batch = client.messages.batches.create(requests=requests)
    print(f"Submitted {len(requests)} files as batch {batch.id}")
    return batch.id

if __name__ == "__main__":
    import sys
    submit_batch(sys.argv[1])

Running python batch_review.py "./my-project/**/*.py" queues every matching file at the 50%-discounted batch rate, then you poll for completion the next morning. For a 400-file repository, that’s the difference between an interactive session costing real money in an afternoon and a scheduled job that costs half as much while you’re asleep.

Step 13: Add Error Handling, Retries, and Spend Monitoring

A script that works on your laptop will eventually hit a rate limit, a timeout, or an overloaded endpoint in production. Wrap every call in retry logic with exponential backoff rather than letting a transient error kill a long batch job:

import time
import anthropic

client = anthropic.Anthropic()

def ask_with_retry(messages, max_retries=5):
    for attempt in range(max_retries):
        try:
            return client.messages.create(
                model="claude-opus-5-5",
                max_tokens=2048,
                messages=messages
            )
        except anthropic.RateLimitError:
            wait = 2 ** attempt
            print(f"Rate limited, waiting {wait}s...")
            time.sleep(wait)
        except anthropic.APIStatusError as e:
            if e.status_code == 529:
                wait = 2 ** attempt
                print(f"Overloaded, waiting {wait}s...")
                time.sleep(wait)
            else:
                raise
    raise RuntimeError("Max retries exceeded")

For spend monitoring, set a hard monthly limit in the Console’s Billing section before you run your first batch job, and check the Usage dashboard daily while you’re still tuning prompt sizes. A 1-million-token context window is powerful, but it’s also the easiest way to turn a $20 testing session into a $200 one if a loop accidentally re-sends the full codebase on every iteration instead of relying on the cache.

Claude Opus 5.5 vs Sonnet 5.5 vs Opus 5 vs Fable 5.1: Which Should You Use?

Picking the wrong model in this family is the fastest way to overpay or underperform. Here’s how the four most relevant Claude models compare as of October 2026:

ModelInput / Output Price (per 1M)Context WindowSWE-bench ProBest For
Claude Opus 5.5$4 / $201M tokens89.9%Long-running agentic coding, large-codebase work
Claude Sonnet 5.5$2 / $101M tokens81.3%Everyday tasks, bug fixes, well-scoped jobs
Claude Opus 5$5 / $251M tokens79.2%Legacy deployments not yet migrated
Claude Fable 5.1Not disclosed in standard pricing tables1M tokens81.2%Maximum-capability reasoning where cost is secondary

The practical takeaway: Opus 5.5 now beats Fable 5.1 on SWE-bench Pro while costing less than Opus 5 did, which is why Anthropic markets it as matching Fable-tier output at Sonnet-adjacent economics. Our coverage of how Opus 5.5 matches Fable 5.1 at 60% less cost digs deeper into that specific comparison if you’re deciding between the two for a production workload. Worth noting too: rival releases from OpenAI have specifically targeted this price point, and GPT-6 Sol and Luna reportedly undercut Opus 5.5 by as much as 50% on list price, so benchmark your actual workload rather than picking a model on pricing alone.

How Claude Opus 5.5 Stacks Up Against GPT-6 Astra and Gemini

Anthropic isn’t the only company shipping long-context, agent-focused flagship models right now, and it’s worth a quick gut check before you commit a production pipeline to Opus 5.5 alone. OpenAI’s GPT-6 Astra and Google’s Gemini 4 Argon both target the same category of multi-step, tool-using work, and all three now ship context windows at or near the 1-million-token mark, which has quietly become table stakes for a flagship coding model in late 2026 rather than a differentiator. Our earlier breakdown of GPT-6 Astra vs Gemini 4 Argon vs DeepSeek covers the pricing and benchmark gap between those three in detail.

Where Opus 5.5 tends to separate itself is in the combination of adaptive thinking that’s on by default and a batch discount that stacks with prompt caching, which lets a well-architected pipeline hit genuinely low per-task costs without sacrificing the reasoning quality that agentic workloads need. If your evaluation criteria are purely benchmark score per dollar, run the same representative task through all three APIs with your own data before standardizing on one, since published benchmarks rarely match the specific mix of code, documents, or tickets your pipeline will actually process. A $20 test across three providers is cheap insurance against locking into the wrong model for six months.

5 Common Pitfalls When Migrating to Claude Opus 5.5

1. Assuming the old extended-thinking flag still applies. Opus 5.5 uses always-on adaptive thinking, so a thinking parameter block written for an older Claude model may be silently ignored or rejected. Check your request payload against the current Opus 5.5 schema before deploying.

2. Sending the full context on every call instead of caching it. This is the single most expensive mistake in this guide. If you’re not using cache_control on the static part of your prompt, you’re paying full price for the same tokens over and over.

3. Using the wrong model ID on Bedrock vs. direct API. claude-opus-5-5 works against Anthropic’s own API, but Bedrock needs the prefixed anthropic.claude-opus-5-5 or a regional variant. Mixing these up produces a model-not-found error that has nothing to do with your actual code logic.

4. Treating batch jobs as synchronous. The Batch API doesn’t return results immediately. If your code polls in a tight loop expecting a sub-second response, you’ll burn through rate limits checking a job that’s still queued.

5. Ignoring the 5-minute vs. 1-hour cache TTL tradeoff. The 5-minute cache write is cheaper ($5/MTok vs. $8/MTok) but expires fast. If your users ask follow-up questions more than five minutes apart, you’ll pay the cache-write cost again on what should have been a cache-read. Match the TTL to your actual usage pattern.

Troubleshooting Guide: 8 Common Errors and How to Fix Them

1. “authentication_error: invalid x-api-key.” Your environment variable isn’t being picked up, usually because you set it in one terminal tab and are running the script from another. Run echo $ANTHROPIC_API_KEY in the exact shell session you’re testing from.

2. “model_not_found: claude-opus-5-5.” Your SDK version predates this model’s release. Run pip install --upgrade anthropic and confirm the version is 0.45.0 or newer.

3. “rate_limit_error” on the very first request. New accounts start on Tier 1 with conservative limits. Check your Console Limits page; the fix is usually to wait for tier upgrades tied to account age and payment history, not a code change.

4. Cache reads showing as zero in usage. This almost always means the cached block isn’t byte-for-byte identical to the previous call. Even a trailing whitespace difference breaks the cache match. Log the exact string you’re sending and diff it against the prior request.

5. “overloaded_error” (HTTP 529) during peak hours. This is a temporary capacity signal, not a bug in your code. Implement exponential backoff as shown in Step 13 rather than failing the request outright.

6. Context window errors despite being under 1M tokens. Remember that token count isn’t the same as character count. A rough rule of thumb is four characters per token for English text, but code and non-English text can run higher. Use the SDK’s token-counting endpoint before assuming you’re under budget.

7. Batch job stuck in “in_progress” for hours. This is normal for large batches. Anthropic doesn’t guarantee a specific completion window, so build your pipeline to poll periodically (every 15-30 minutes) rather than expecting near-real-time results.

8. Unexpectedly high bill despite using caching. Check whether you’re using the 1-hour TTL but issuing requests more than an hour apart, or whether a bug in your loop is regenerating the cached block with a dynamic timestamp or ID embedded in it, which breaks cache matching silently on every single call.

Securing Your API Key in a Real Deployment

Everything in this tutorial so far assumes a single developer running scripts locally, which is fine for testing but not how a production key should live. Once you’re ready to deploy repo-digest or anything like it beyond your own laptop, move the key out of shell environment variables and into a proper secrets manager, whether that’s AWS Secrets Manager, Google Secret Manager, HashiCorp Vault, or even your CI/CD platform’s built-in encrypted secrets store. Pulling the key at runtime from a secrets manager means it never sits in a .env file that could end up committed by accident, and it means rotating a compromised key doesn’t require redeploying every service that uses it.

Scope keys narrowly where Anthropic’s Console allows it, create a separate key per service or environment (one for staging, one for production, one for the nightly batch job) rather than sharing a single key across your whole stack, and set a conservative spend limit on each one individually. If a staging key leaks, you want the damage capped at whatever staging-level spend limit you set, not your entire organization’s monthly budget. It’s a five-minute setup step that turns a potential incident into a minor inconvenience.

Advanced Tips for Production Deployments

Once the basic setup is solid, a few patterns separate a demo from something you’d trust in production. Structure your prompts so the largest, most stable content (codebase dumps, policy documents, historical logs) always comes first in the message, with the smallest and most variable content (the actual user question) last. This maximizes your cache hit rate because Anthropic’s caching matches on a prefix basis, not an exact full-string match.

For agentic workflows that run for extended periods, don’t let the model’s context grow unbounded across a long conversation. Periodically summarize earlier turns and replace them with the summary, keeping your effective context well under the 1M ceiling even on sessions that would otherwise run for hours. This also keeps your per-call cost predictable instead of climbing linearly with conversation length.

If you’re running mixed workloads, route by task complexity rather than defaulting everything to Opus 5.5. A simple pattern: use Claude Sonnet 5.5 for the first pass on a request, and only escalate to Opus 5.5 if the task is flagged as complex (multi-file refactor, ambiguous requirements, security-sensitive code). This tiered approach, discussed in our Sonnet 5.5 model comparison, can cut blended API costs by 40-60% compared to sending every request to the flagship model.

Finally, if you’re building anything that runs autonomously for long stretches, look into Anthropic’s broader agent tooling rather than hand-rolling your own loop. Our Claude Agent SDK walkthrough covers the higher-level framework Anthropic ships specifically for multi-step, tool-using agents, which handles a lot of the state management this tutorial’s manual scripts don’t.

Frequently Asked Questions

Is Claude Opus 5.5 cheaper than Claude Opus 5?
Yes. Opus 5.5 bills at $4 per million input tokens and $20 per million output tokens, versus $5 and $25 for Opus 5, a 20% price cut on standard requests. Anthropic separately describes the model as 40% cheaper to run overall, a figure that factors in efficiency gains beyond the listed per-token rate.

What’s the exact model ID I should use in my code?
Use claude-opus-5-5 for Anthropic’s direct API. On AWS Bedrock, use anthropic.claude-opus-5-5 or a regional variant like us.anthropic.claude-opus-5-5. On Microsoft Foundry, the ID is claude-opus-5-5, matching Anthropic’s own naming.

Does Claude Opus 5.5 support the same context window as Claude Sonnet 5.5?
Yes, both models ship with a 1-million-token context window by default and a maximum output of 128,000 tokens, according to Anthropic’s documentation on Amazon Bedrock model availability.

How much does prompt caching actually save in practice?
Cache reads cost $0.20 per million tokens, which is 5% of the $4 standard input rate, a 95% discount. The savings scale directly with how often you reuse the same cached context within the TTL window you choose (5 minutes or 1 hour).

Can I use Claude Opus 5.5 for free to test it first?
Anthropic doesn’t offer a standing free API tier for Opus 5.5; you need billing enabled on your Console account before generating an API key. New accounts typically get a small initial credit, but check your own Console dashboard for current promotional credit, since this changes over time.

Is Opus 5.5 better than Claude Fable 5.1 for coding tasks?
On SWE-bench Pro, Opus 5.5 scores 89.9% versus Fable 5.1’s 81.2%, per BenchLM’s October 2026 leaderboard. Anthropic’s own benchmark separately shows Opus 5.5 at its default medium effort setting outperforming Fable 5.1 at maximum effort, which suggests Opus 5.5 is now the stronger coding option for most teams.

What happens if I exceed the 128,000 output token limit?
The API truncates the response at that ceiling. For tasks that genuinely need longer output, break the job into sequential calls, feeding the prior output back as context for the continuation, rather than expecting a single call to exceed the documented maximum.

Should I migrate existing Opus 5 code to Opus 5.5 immediately?
In most cases, yes, since it’s a straight price cut with better benchmark scores and the same context window ceiling. The main thing to verify first is whether your code relies on an explicit extended-thinking parameter that behaves differently under Opus 5.5’s always-on adaptive thinking model.

Related Coverage

Nadia Dubois

Nadia Dubois

AI & Innovation Editor

Nadia Dubois is the AI & Innovation Editor at Tech Insider, where she tracks the rapid evolution of artificial intelligence, from foundation models to real-world enterprise deployment. She previously covered AI and startups for La Tribune and contributed to MIT Technology Review's European coverage. Nadia specializes in generative AI, AI regulation, and the intersection of technology and European industrial policy. She holds a dual degree in Computational Linguistics and Journalism from Sciences Po Paris.

View all articles