What to check before upgrading the Anthropic SDK
By Flavio
Tagged: AI
Upgrading the Anthropic SDK changes the API version your app sends. Check sampling parameters, authentication, message history, and output before you ship.
Upgrading the Anthropic SDK can change which requests the Claude API accepts, even if you keep the same model and prompt.
On October 21, 2026, Anthropic shipped API version 2026-10-21, Python SDK 2.0.0, TypeScript SDK 1.0.0, new major versions of its other SDKs, and an updated ant CLI. All of them default to the new API contract. You can check the exact version numbers for every language in the release notes.
If your app talks to Claude, plan a proper migration before bumping your dependencies. Here’s how it breaks down:
One quick caveat before you start: if you’re running on Amazon Bedrock with a model older than Claude 4.7, stay on your current SDK. Bedrock only supports the new API version for Claude 4.7 and newer models, so read the migration guide before touching those integrations.
Save a working baseline
Before you touch your packages, run your existing test suite and save a handful of real inputs and outputs. Make sure your sample includes a multi-turn conversation with history alongside single prompts.
Write down the model ID, SDK version, and API version next to those outputs. The API version travels in the anthropic-version request header and controls the request and response contract independently of the model you pick.
In a Node.js project using npm, check which SDK version you have installed:
npm ls @anthropic-ai/sdk
Commit your working dependency files before upgrading. Leave the model ID and prompts untouched while you migrate so any shift in behavior points straight to the SDK change.
Sampling parameters are gone
The new API version returns HTTP 400 whenever a request includes temperature, top_p, or top_k, even if you pass their default values. Pull them out. The new SDK drops those arguments too, so your code can fail locally before a request even leaves your server.
There’s no replacement for custom sampling under the new contract. If a workflow depends on it, you can stay on 2023-06-01, as covered in Anthropic’s migration guide.
Shared wrappers around multiple providers make this easy to miss. A helper function might quietly attach temperature: 0 to every call even when your feature code never mentions it. If you route calls through something like the Vercel AI SDK, check its Anthropic provider setup as well.
Here’s an old request snippet that will now break:
const request = {
model,
max_tokens: 256,
messages,
temperature: 0,
}
Keep the same model and messages, and drop the sampling field completely:
const request = {
model,
max_tokens: 256,
messages,
}
Passing the default temperature still triggers an error. In TypeScript, fix the type error properly instead of casting around it, because extra fields still make it onto the wire at runtime.
Start by checking your wrapper code, then compare your app’s outputs against your baseline once those fields are gone. Even when requests succeed again, dropping a sampling setting can shift the replies your app depends on.
Check authentication around the SDK
For direct Claude API requests, the SDK now sends your API key in Authorization: Bearer instead of X-Api-Key. Anthropic’s API still accepts both headers, so live calls go through fine, while your proxies, middleware, mocks, and log redaction rules might still be looking for X-Api-Key.
A test that asserts X-Api-Key can start failing even when auth works. More importantly, a custom logger that only scrubs X-Api-Key could suddenly leave your bearer token in plain text.
Trace the full request path between your app and Anthropic, and keep real API keys out of debug logs while you do it.
Use a fake key in any test that inspects outgoing headers. Verify that your logger scrubs both Authorization and X-Api-Key, regardless of header casing, since a gateway elsewhere in your stack might still use the older header.
Check message construction too
The API is stricter now about which message roles can hold certain blocks:
| What your request contains | What to change |
|---|---|
A document block directly in an assistant message | Send the document in a user message |
A non-empty citations array on a user text block, including inside search_result | Remove that array from the user text block |
| Citations on assistant text from an earlier reply | Keep them; they are still accepted |
citations: { enabled: true } on a document or search result | Keep it; enabling citations is still supported |
Don’t strip citations off every message just to silence an error. Fix the specific role and block combination that gets rejected. Documents nested inside a tool result, like a web fetch result returned by Claude, are still allowed.
In Python, MessageParam is now a union, so pass a dictionary instead of calling MessageParam(...) as a constructor. The migration guide lists the rest of the language-specific changes.
Pay extra attention to stored conversations. A fresh chat can pass every check while replaying an older thread breaks.
Upgrade and test the request
Do the upgrade on a separate branch. In an npm project, install the SDK release you’ve reviewed and commit package.json and package-lock.json together. TypeScript 1.0.0 is the first release on the new API version, so read the newer release notes too if you jump straight to a later version.
Next, search your codebase for the spots that likely need attention:
rg -n 'temperature|top_p|top_k|MessageParam\(|X-Api-Key|x-api-key' src tests
Swap src and tests for your project’s folders. Check each match before deleting anything, because other providers in your codebase might still rely on those settings.
Once you’ve cleaned up what you found, run a tiny standalone request outside your app’s wrappers. Save this file as sdk-smoke.mjs in your project:
import Anthropic from '@anthropic-ai/sdk'
const model = process.env.ANTHROPIC_MODEL
if (!model) throw new Error('Set ANTHROPIC_MODEL to your existing model ID')
const client = new Anthropic()
const message = await client.messages.create({
model,
max_tokens: 256,
messages: [{ role: 'user', content: 'What is a dependency lockfile?' }],
})
for (const block of message.content) {
if (block.type === 'text') console.log(block.text)
}
Run it on your server with ANTHROPIC_API_KEY and ANTHROPIC_MODEL set in your environment:
node sdk-smoke.mjs
Use the model ID your app already runs, and remember this hits the live API so it’ll show up on your bill. The client pulls your key from the environment, so keep this file strictly server-side and out of browser code.
If the smoke script works while your app fails, compare what your wrapper and gateway send over the wire. If TypeScript refuses to compile before you get that far, start by fixing the SDK’s updated types.
From there, test the real paths a quick smoke script skips:
- Start a conversation, then continue it with saved history.
- Send a document through your real application workflow.
- Run a tool call and send back its result.
- Route requests through any proxy or gateway you use.
- Confirm your logs still scrub credentials.
Finish by re-running your baseline inputs and checking that the answers still hold up.
If your app extracts invoice fields, verify the extracted fields and amounts against known invoices. If it triggers tool calls, check which tool it picks and the arguments it passes. The wording can shift slightly from run to run, as long as the behavior your app depends on stays solid.
Check the rest of the migration guide
The checks above cover the most common request breakages, though the major SDK updates also drop older features outside the API version itself. In TypeScript, check whether you still use the removed legacy Text Completions API or the old tool-runner compactionControl option. If you call the Admin or Enterprise Analytics APIs, check for renamed response fields too.
Pinning anthropic-version back to an older date won’t restore removed SDK methods or types. As the TypeScript SDK docs point out, overriding that header can leave the SDK’s types out of sync with what the API expects.
If you need to roll back, revert your application code and dependency files together. In an npm project, npm ci reinstalls the exact versions recorded in your lockfile. Hang on to your baseline inputs so you can run the same checks again on your next attempt.
Want me to talk about your product? You can sponsor this site.
Related posts about ai: