Claude API 2026-10-21: Fixing the Temperature 400 Error
On API version 2026-10-21, any Messages request that sends temperature, top_p or top_k returns a 400 error, even at the default value. Delete those three fields, move any document block out of assistant messages, strip citations from user text blocks, and check the SDK's own breaking changes, such as API keys now sent as Authorization: Bearer.
If your Claude integration started failing after a routine dependency bump, this is the likely cause. The new SDK majors send anthropic-version: 2026-10-21 by default, and that version changes what the API accepts. Below is what changed, why, and the order I would do the upgrade in, with before and after examples. Everything here comes from Anthropic's migration guide and API versions page, as of late November 2026.
Why does Claude return a 400 error for temperature?
Claude returns a 400 error for temperature because API version 2026-10-21 removes the temperature, top_p and top_k request parameters from the Messages API. The migration guide says a request that sends any of them returns a 400 error, even at the parameter's default value, and the same applies to Message Batch requests.
The catch is that most code which sets temperature: 1 or temperature: 0.7 never fails on the old version, 2023-06-01. You hit the error only after you upgrade an SDK, because the SDK changes the version header for you. Anthropic's guide lists the first releases that send 2026-10-21 by default:
| SDK | First release on 2026-10-21 |
|---|---|
Python anthropic | 2.0.0 |
TypeScript @anthropic-ai/sdk | 1.0.0 |
Go anthropic-sdk-go | 2.0.0 (module path ends in /v2) |
Java anthropic-java | 3.0.0 |
C# Anthropic | 13.0.0 |
PHP anthropic-ai/sdk | 1.0.0 |
Ruby anthropic gem | 2.0.0 |
ant CLI | 2.0.0 |
The Python SDK's v2.0.0 release on GitHub, dated 21 October, lists support for the new API version as a breaking change. If you call the API without an SDK, nothing changes until you set the anthropic-version header to 2026-10-21 yourself.
What does removing temperature change in your output?
Removing temperature changes nothing for models that already accept only the default values, and removes a control you were relying on for older models that accepted others. According to the migration guide, a request without these parameters samples with their defaults, including a temperature of 1.0, exactly as a 2023-06-01 request that leaves them out. Claude 4.7 and later models already accept only the defaults, so they sample as before.
On models that accepted other values, such as Claude Sonnet 4.6, a request that lowered temperature for more consistent output loses that effect, and the guide is explicit that no other setting replaces it. If a call truly depends on a low temperature, the guide's options are to stop sending it and accept the default, or keep that request on 2023-06-01.
In my experience, a low temperature was often standing in for something better. If you wanted consistent formats, use structured outputs; my guide to reliable JSON from LLMs covers the pattern. If you wanted repeatable answers for tests, assert on structure and content rather than exact strings.
What else breaks on API version 2026-10-21?
Besides sampling parameters, API version 2026-10-21 rejects two message shapes and drops some duplicate response fields. The versions page lists the full set:
- Documents in assistant messages. A request that places a
documentblock directly in anassistantmessage returns a 400 error. Send documents inusermessages. A document nested inside another block, such as a web fetch result Claude returned, is still accepted. - Citations in user messages. A
textblock with a non-emptycitationsarray in ausermessage returns a 400 error, directly or inside asearch_resultblock. Citations on Claude's own replies, and the"citations": {"enabled": true}setting on documents, are still fine. - Admin API and Enterprise Analytics fields. Deprecated duplicates are removed: for example, RBAC roles return
display_nameinstead ofname, and API keys returnscope.workspace_idinstead ofworkspace_id. These fail silently, because the field is just absent.
The two message errors usually come from history-building code that copies Claude's response blocks into the wrong role. Fix them where the message is assembled.
What changed in the SDKs themselves?
The new SDK majors carry their own breaking changes, separate from the API. The migration guide's SDK section lists them; these are the ones I expect most teams to hit:
- API keys are sent as `Authorization: Bearer`. The SDK and CLI no longer use the
X-Api-Keyheader. The Claude API accepts either, but any proxy, gateway, log filter or test stub that readsX-Api-Keymust change. If you protect keys behind a proxy, as in my post on protecting API keys in AI web apps, check it first. - A client holds one credential. In Python, passing both
api_keyandauth_tokento one client now raises aValueError. - Client-side compaction is removed from the tool runner in TypeScript and Ruby. Use server-side compaction instead, with a trigger of at least 50,000 tokens.
- Text Completions is removed from the TypeScript, Go, Java and Ruby SDKs and the CLI. Use the Messages API.
- `MessageParam` is a union with one type per role in every SDK. Plain dict or object literals need no change; constructing the type by name may.
- `betas` is removed from the non-beta Models methods. Call
client.beta.modelsto send beta headers.
The licence of every SDK and the CLI also changes to Apache 2.0, which needs no code change but may matter to your licence tracking.
How do you upgrade to 2026-10-21 safely?
Upgrade in this order, because the request-shape fixes also work on 2023-06-01 and can ship before the SDK bump:
- Inventory. Search for
temperature,top_p,top_k(and spellings liketopP),extra_body,documentblocks in assistant turns, andcitationsin anything you send back as user input. - Decide on non-default sampling. List every call that sets a non-default value on a model older than Claude 4.7, check its output at the default, and agree what to do before deleting anything.
- Fix the request shapes on the old version. Remove the three fields, move documents to user messages, strip citations from user text. Ship this first.
- Check Amazon Bedrock. The versions page says that on Bedrock, 2026-10-21 is available only for Claude 4.7 and later models. Keep calls to older Bedrock models on the version and SDK they use today.
- Upgrade the SDK to the release in the table above, plus any platform packages released alongside it.
- Apply the SDK changes: header handling in proxies, one credential per client, compaction, removed Text Completions calls.
- Test against 2026-10-21, then release the upgrade together with your fixes.
Here is what the common fixes look like before and after:
| Change | Before (2023-06-01) | After (2026-10-21) |
|---|---|---|
| Sampling | messages.create(model=..., max_tokens=1024, temperature=0.2, messages=[...]) | messages.create(model=..., max_tokens=1024, messages=[...]) |
| Raw HTTP header | anthropic-version: 2023-06-01 | anthropic-version: 2026-10-21 |
| Auth header seen by a proxy | X-Api-Key: <key> | Authorization: Bearer <key> |
| TypeScript tool runner | compactionControl: { enabled: true, contextTokenThreshold: 100_000 } | context_management: { edits: [{ type: "compact_20260112", trigger: { type: "input_tokens", value: 100_000 } }] } with the compact-2026-01-12 beta |
| Python per-request key | extra_headers={"X-Api-Key": other_key} | extra_headers={"Authorization": f"Bearer {other_key}"} |
Two places hide the sampling fields from a quick search. The first is configuration: a temperature key in a YAML file, an environment variable or a wrapper function's default argument still ends up in the request. The second is third-party libraries that sit between your code and the API, such as an orchestration framework or an LLM gateway, which may send these fields when configured with them. Check how each one sets anthropic-version and what it forwards.
Tests need attention too. A unit test that asserts the request contains temperature: 0 will break for the right reason; rewrite it to assert on fields that still exist, such as max_tokens, stop_sequences or metadata, so it keeps guarding something useful.
If you are wiring Claude into a web app for the first time, my Next.js integration guide shows the basic request shape that works on either version.
Work with me
I upgrade and maintain Claude and OpenAI integrations in production, including SDK migrations, proxies and test suites. See AI integration and full-stack development, or look at my work and book a scoping call.
Frequently asked
Can I keep sending temperature by staying on the old API version?
Yes. The migration guide says a request that relies on a non-default value can stay on 2023-06-01. With an SDK, that means staying on your current major or overriding the version, and the override keeps you off the new SDK's defaults, so treat it as temporary.
Does temperature 1 still cause an error on 2026-10-21?
Yes. Anthropic's guide says the 400 error happens even at the parameter's default value, so temperature: 1 fails as well. Remove the field entirely rather than setting it to the default.
Why did my proxy stop authenticating after the SDK upgrade?
The new SDK majors send your API key as Authorization: Bearer instead of X-Api-Key. A proxy or gateway that reads only X-Api-Key will not find the key. Update it to read Authorization, or send X-Api-Key yourself as the migration guide describes.
Do I have to upgrade everything at once?
No. The fixes to request shapes work on both versions, so ship them first. Then upgrade one service or SDK at a time, testing each against 2026-10-21 before release.
Sources
Related services
Building something like this?
Naman Gundaniya takes on full-stack and AI projects: fixed quote after a free 30-minute scoping call, replies within 24 hours.
Get in touch