Claude API 2026-10-21: why temperature returns a 400 error

Convika Team19 min read

  • llm-apis
  • ai-models
  • claude-code
On this page

As of October 24, 2026, 08:38 JST (October 23, 23:38 UTC). Every fact that can change carries the time it was checked, in JST (UTC+9). This page covers Claude API version 2026-10-21, released October 21, 2026, and the SDK releases that send it.

Claude API version 2026-10-21, released by Anthropic on October 21, 2026, returns a 400 error for any request that sends temperature, top_p, or top_k, even at the default value. Python anthropic 2.0.0, TypeScript @anthropic-ai/sdk 1.0.0, and the other SDK majors of that day send it by default.

So upgrading the SDK is what switches you. Remove the three parameters, or keep that request on 2023-06-01: those are the two choices in Anthropic's migration guide. Without them, a request samples with the defaults, including a temperature of 1.0. On Claude 4.7 and later models, which already accepted only the defaults, the output stays the same once you remove them. On a model such as Claude Sonnet 4.6, a request that lowered temperature loses that effect, and in Anthropic's words, "No other setting replaces it." Anthropic hasn't published the error's text or an end date for 2023-06-01 (checked 08:36 JST).

This page tested the upgrade on October 24 at 07:55 JST against a local server that records what each SDK sends, with no API key and no request to Anthropic. pip install -U anthropic moved 1.17.0 to 2.2.0 and the header from 2023-06-01 to 2026-10-21. A temperature in extra_body, the route the Python SDK's own v1 guide gave for older models, went out with the new version. So did the temperature of LangChain's ChatAnthropic, after pip printed a dependency ERROR and installed 2.2.0 anyway. npm update left a ^0.137.0 TypeScript project on 0.137.0.

Below: what changed in the API, the first release of each SDK that switches, what happens to your code after the upgrade, every request that now returns a 400, the SDK changes that come with it, how to keep one request on 2023-06-01, Amazon Bedrock and Google Cloud, the ant CLI, and the steps.

What changed on October 21, 2026

Anthropic's release notes for October 21, 2026 say: "We've released API version 2026-10-21." The same entry lists SDK and CLI releases "that send API version 2026-10-21 by default" (checked 08:36 JST). The version changes four things, per Anthropic's versions page and migration guide:

What your request or code doesOn 2026-10-21What to do
Sends temperature, top_p, or top_k to the Messages API, token counting, or a Message BatchThe request "returns a 400 error, even at the parameter's default value"Delete the three fields, or keep that request on 2023-06-01
Places a document block directly in an assistant messageReturns a 400 error. A document nested inside another block, "such as a web fetch tool result that Claude returned, is still accepted"Send the document in a user message
Sends a text block with a non-empty citations array in a user message, directly or inside a search_result blockReturns a 400 error. Citations in assistant messages and the "citations": {"enabled": true} setting are still acceptedRemove citations from those blocks and keep the text
Reads old field names from the Admin API or the Claude Enterprise Analytics APIThe responses "no longer include the old names of renamed fields"Read role_ids, rbac_group_id, display_name, group.type, scope, actor.email_address, and data (table below)

The versions page lists no change for any other endpoint. The renamed fields:

EndpointsOld nameNew name
RBAC groups: create, list, retrieve, updaterolesrole_ids
RBAC group members: list, add, and the response to removing onegroup_idrbac_group_id
RBAC roles: list, retrievenamedisplay_name
Organization and workspace rate limitsgroup_typegroup.type
API keys: list, retrieve, updateworkspace_idscope, with different values: a key bound to the Default Workspace now shows that workspace's real ID in scope.workspace_id, where workspace_id was null; an all-workspaces key has a scope of {"type": "organization"}, with no workspace_id
Analytics per-user usage and cost reportsactor.emailactor.email_address
Analytics activity summariessummariesdata

The version is available on "the Claude API, Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed), Microsoft Foundry, and Claude Models on Google Cloud (Google managed)", and on Amazon Bedrock only "for Claude 4.7 and later models" (versions page, checked 08:36 JST). Retirement dates of the models themselves are a separate calendar: AI model retirements from November 2026 to February 2027.

Which SDK release switches you

Anthropic's guide says: "If you use an SDK, your requests use the API version that was current when your SDK's major version was released." Its SDK overview adds that "a new major version comes with each new API version." Every release older than the ones below sends 2023-06-01.

SDKPackageFirst release on 2026-10-21Published (registry, October 21)Last release on 2023-06-01Newest (checked 08:38 JST)
Pythonanthropic (PyPI)2.0.015:51 UTC (October 22, 00:51 JST)1.17.0, October 202.3.0, October 23
TypeScript@anthropic-ai/sdk (npm)1.0.016:00 UTC (01:00 JST)0.137.0, October 201.3.0, October 23
C#Anthropic (NuGet)13.0.015:53 UTC (00:53 JST)12.60.0, October 2013.3.0, October 23
Gogithub.com/anthropics/anthropic-sdk-go/v2 (Go module proxy)v2.0.015:44 UTC (00:44 JST)v1.84.0, October 20v2.3.0, October 23
Javacom.anthropic:anthropic-java (Maven Central)3.0.016:02 UTC (01:02 JST)2.75.0, October 203.3.0, October 23
PHPanthropic-ai/sdk (Packagist)1.0.015:47 UTC (00:47 JST)0.61.0, October 201.3.0, October 23
Rubyanthropic (RubyGems)2.0.016:02 UTC (01:02 JST)1.82.0, October 202.3.0, October 23
CLIant (GitHub releases)2.0.017:30 UTC (02:30 JST)1.44.0, October 202.2.0, October 23

The first-release numbers are the ones Anthropic's release notes list. The times are each registry's own (Maven Central: the file date of the 3.0.0 POM), read between 07:53 and 08:00 JST on October 24; the newest versions were read again at 08:38. The TypeScript platform packages, @anthropic-ai/bedrock-sdk, vertex-sdk, foundry-sdk, aws-sdk, and google-cloud-sdk, reached 1.0.0 between 15:56 and 16:04 UTC the same day; Anthropic's guide says to move them to v1 in the same upgrade, "Otherwise your package manager installs a second, older copy of @anthropic-ai/sdk for it." The Python and TypeScript releases since then (2.1.0 to 2.3.0, 1.1.0 to 1.3.0) add features and fix the tool runner and the client; their release notes on GitHub say nothing about sampling (checked 08:36 JST). New 2.x and 1.x releases keep coming, so this page names the newest version only in the table above.

Whether an update moves you to the new major depends on the package manager:

How you updateResultSource
pip install -U anthropic with no upper boundInstalls the newest 2.xThis page's test (1.17.0 to 2.2.0, 07:55 JST)
pip install -U "anthropic<2"Stays on 1.xThis page's test (1.16.0 to 1.17.0)
npm update with "@anthropic-ai/sdk": "^0.137.0"Stays on 0.137.0; npm outdated lists the newest 1.x under "Latest"This page's test ("Latest 1.2.0", 07:56 JST)
npm install @anthropic-ai/sdk in a new projectWrites the newest 1.xThis page's test (^1.2.0, 07:56 JST)
composer update"stays within your current version constraint"; composer require "anthropic-ai/sdk" moves to 1.xAnthropic's guide
Gov2 has a new import path, github.com/anthropics/anthropic-sdk-go/v2, so code on the old path stays on v1Anthropic's guide
brew upgrade for the ant CLIAnthropic's Homebrew tap moved to 2.0.0 on October 21 at 17:44 UTCanthropics/homebrew-tap commit history (08:00 JST)

A Python project that installs anthropic without an upper bound took the new API version with its next pip install -U. Anthropic's guide treats the move as a step you take together with your fixes ("Release the upgrade together with your fixes from the next step"); an install with no upper bound takes that step for you.

What happens to your code after the upgrade

This page installed each SDK and pointed it at a local server that recorded the headers and body of each request, with a dummy key (October 24, 07:55–07:59 JST; Python 3.14.3, pip 26.0, Node 22.23.4, TypeScript 5.9.3). No request went to Anthropic, so the 400 itself comes from Anthropic's guide, not from this test.

What you haveWhat the test recorded after the upgradeWhat you do
Python code that passes temperature=0.2 as a keywordOn 1.17.0 and 2.2.0 the SDK raised TypeError: Messages.create() got an unexpected keyword argument 'temperature' before sending anything. The keyword has been gone since 1.0.0 (August 20, 2026); 0.125.0 still sent itDelete it. A jump from 0.x straight to 2.x shows this error first
Python code that sends temperature through extra_body, as the v1 migration guide advised "for an older model that still does"1.17.0 sent it with anthropic-version: 2023-06-01; 2.2.0 sent it with 2026-10-21, which returns a 400Delete it, or keep that request on 2023-06-01 (below)
Python with langchain-anthropic 1.7.6Its metadata requires anthropic<2.0.0,>=0.120.0. pip install -U anthropic printed ERROR: pip's dependency resolver does not currently take into account all the packages that are installed and installed 2.2.0 anyway. ChatAnthropic(temperature=0.2) then sent temperature with 2026-10-21; without a temperature, it sent nonepip install "anthropic<2" until langchain-anthropic allows 2.x, or drop temperature from ChatAnthropic
A Python dependency pinned below 21.17.0 kept sending 2023-06-01Nothing breaks; move when you're ready
TypeScript with a temperature in a request literal, on 1.2.0tsc stopped with TS2769: "'temperature' does not exist in type 'MessageCreateParamsNonStreaming'"Delete it
JavaScript, or TypeScript where the request object isn't checked against the SDK's types, on 1.2.0The SDK sent temperature: 0.2 with 2026-10-21, which returns a 400Delete it
TypeScript on ^0.137.0npm update kept 0.137.0, which sends 2023-06-01Nothing breaks until you install 1.x
C# through the IChatClient adapters (AsIChatClient()), on 13.xNot tested. Anthropic's guide: the adapters "now ignore ChatOptions.Temperature, ChatOptions.TopK, and ChatOptions.TopP"Nothing fails, and the output samples at the defaults. Check that the default output works for that call
A hand-built HTTP request with its own anthropic-version headerUnchanged: the guide says to "set the anthropic-version header to 2026-10-21" when you choose to moveNothing breaks until you change the header

Agents and MCP servers you wrote that call the Messages API are in the same rows as any other code: what decides is the SDK major they install and whether they send the three parameters.

If you use Claude Code to fix the error, Claude Code 2.1.307, released October 21 at 22:17 UTC, "Added /claude-api api-version to move Claude API code to API version 2026-10-21" (Claude Code changelog, checked 07:56 JST). If agents in your repository run pip install -U or npm install on their own, a PreToolUse hook can stop that command until the code is ready: Claude Code hooks: how to block a command before it runs.

Everything that returns a 400 on 2026-10-21

Request contentOn 2023-06-01On 2026-10-21Fix
temperature, top_p, or top_k at a non-default value, on Claude 4.7 and later models400400Delete it
The same at a non-default value, on a model that accepts other values, such as Claude Sonnet 4.6Accepted400Delete it if the default output works for that call; otherwise keep the call on 2023-06-01
Any of the three at its default, such as "temperature": 1Accepted400Delete it; the default applies anyway
A document block directly in an assistant messageAccepted400Move the document to a user message
A text block with non-empty citations in a user message, directly or in a search_resultAccepted400Remove citations, keep the text

The 2023-06-01 column for Claude 4.7 and later is from Anthropic's model deprecations page, whose parameter table says earlier API versions return the error "when set to a non-default value on Claude 4.7 and later models and Claude Mythos Preview" (checked 08:36 JST). Anthropic's Messages guide gives the replacement: "Omit them from request payloads and use prompting to guide the model's behavior instead."

Anthropic's errors page lists the message text of other 400 errors, such as forced tool use on models that don't support it, but not of this one, and neither does the migration guide (checked 08:36 JST). A request without an API key gets a 401 authentication_error, "x-api-key header is required", before the parameters are checked (07:55 JST), so this page couldn't read the text without a key.

The SDK changes that come with the upgrade

The new majors also change things that don't depend on the API version (Anthropic's guide, "SDK and CLI changes"):

ChangeWhich SDKsWhat to do
The API key goes out as Authorization: Bearer <key> instead of X-Api-KeyAll, and the CLI. The Foundry clients still send x-api-keyChange a proxy, gateway, middleware, log filter, or test stub that reads X-Api-Key. "The Claude API accepts a key in either header."
A client holds one credentialAll seven SDKs. Two in the constructor raise ValueError in Python and throw TypeError in TypeScriptPass one. With none passed, ANTHROPIC_API_KEY comes before ANTHROPIC_AUTH_TOKEN
Text Completions is removedTypeScript, Go, Java, Ruby, and the CLIUse the Messages API
MessageParam is one type per roleAll seven SDKsIn Python, calling MessageParam(...) raises TypeError; write the message as a dict
Go needs 1.25 or later, and the module path ends in /v2GoChange every import, then go get github.com/anthropics/anthropic-sdk-go/v2
Client-side compaction in the tool runner is removedTypeScript, RubyUse server-side compaction
The license is Apache 2.0 instead of MITAll new majors; "Earlier versions remain under the MIT License"Update your license records

In this page's test, the 2.2.0 and 1.2.0 clients sent the key as Authorization, where 1.17.0 and 0.137.0 sent X-Api-Key.

Keep one request on 2023-06-01

For a request that relies on a non-default value, Anthropic's guide says to "either stop sending the parameter, or keep that request on 2023-06-01." It doesn't show how to keep one request there with a new SDK. Two ways worked in this page's test, which shows what the SDK sends, not what the API answers:

  • Hold the SDK below the new major. anthropic<2 kept 1.17.0, and ^0.137.0 kept 0.137.0. Every request through that SDK stays on 2023-06-01. On Python 1.x the value goes in extra_body, since the keyword is gone.
  • Set the header on that one request. On Python 2.2.0, extra_headers={"anthropic-version": "2023-06-01"} together with extra_body={"temperature": 0.2} sent both. On TypeScript 1.2.0, { headers: { "anthropic-version": "2023-06-01" } } as the second argument of messages.create sent 2023-06-01.

On 2023-06-01 the value still has to be one the model accepts: a non-default value on Claude 4.7 and later models returns a 400 there too. Neither Anthropic's versions page nor the guide gives an end date for 2023-06-01; the versions page says only, "Anthropic recommends using the latest API version whenever possible" (checked 08:36 JST).

Amazon Bedrock and Google Cloud

PlatformWhat Anthropic says (checked 08:37 JST)What the platform's own page says
Amazon Bedrock, Claude 4.7 and later2026-10-21 is availableAWS's Messages parameters page says anthropic_version "must be bedrock-2023-05-31" and doesn't mention 2026-10-21 (07:57 and 08:37 JST)
Amazon Bedrock, older models (Claude Opus 4.6 and earlier)Not available. Requests that send it "can return a 400 error"; "keep the SDK on the version you use today, and pin that version where you install it". The Boto3 example "sets anthropic_version in its request body and isn't affected"Same page as above
Claude Models on Google Cloud (Google managed)Set anthropic_version in the body "to vertex-2023-10-16, or to API version 2026-10-21"Google's Claude page, "Last updated 2026-10-22 UTC", shows vertex-2023-10-16 and doesn't mention 2026-10-21 (07:57 and 08:37 JST)
Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed), Microsoft FoundryAvailableNot read for this page

The SDKs' Bedrock and Google Cloud clients switch with the main SDK: the guide says the new versions send 2026-10-21 "including their Amazon Bedrock and Google Cloud clients." On Bedrock, that is the case to watch: an unpinned upgrade moves calls to older models onto a version they don't support.

The ant CLI 2.0.0

The ant CLI 2.0.0 sends 2026-10-21 too, and the guide says the three parameters are gone from its flags. It also drops --api-key and --auth-token: "A command that still passes one stops with flag provided but not defined." Use ANTHROPIC_API_KEY, --api-key-stdin, or ant auth login for the key, and ANTHROPIC_AUTH_TOKEN or --auth-token-stdin for a token. With go install, the path is now github.com/anthropics/anthropic-cli/v2/cmd/ant@latest; the old path "keeps installing the latest v1 release, with no error or warning." Homebrew (anthropics/tap/ant) and the release downloads keep their names, and the tap has shipped 2.x since October 21.

Fix the 400 and move to 2026-10-21

1. See which API version you send

Run pip show anthropic or npm ls @anthropic-ai/sdk. Python 2.0.0, TypeScript 1.0.0, C# 13.0.0, Go v2, Java 3.0.0, PHP 1.0.0, Ruby 2.0.0, and ant 2.0.0 or later send 2026-10-21. Then search for a version set by hand: git grep -niE 'anthropic[-_]version'.

2. Find the three parameters

Run git grep -niwE 'temperature|top_?p|top_?k'. It finds Python's temperature=, TypeScript's topP, Go's TopK, Java's .temperature(, extra_body entries, Message Batch params, and --temperature in shell scripts. Check the settings of any library between your code and the API, such as LangChain's ChatAnthropic(temperature=...).

3. Decide for each call that sets a non-default value

On Claude 4.7 and later models, delete the value: those models already accept only the defaults. On a model that accepts other values, such as Claude Sonnet 4.6, run the call without it and check the output. If the default output doesn't work for that call, keep it on 2023-06-01 (above).

4. Fix the other changes

Move document blocks out of assistant messages, remove citations from text blocks in user messages, and read the new Admin API and Analytics field names. Change any proxy or gateway that reads X-Api-Key.

5. Upgrade, and bound the next major

Install the new major and give it an upper bound, such as anthropic>=2,<3, so the next API version arrives when you choose it. Upgrade the TypeScript platform packages to 1.x in the same change. On Bedrock with a model older than Claude 4.7, stay on the old major and pin it.

6. Test against 2026-10-21

Anthropic's guide: "Test your integration against 2026-10-21 before you release." A request that still sends one of the three parameters fails with a 400 on every model, so one test call per code path finds what the search missed.

Updates to this page

  • October 24, 2026, 08:38 JST: first version.

This page changes when Anthropic publishes the error's text or an end date for 2023-06-01, when it changes the migration guide, when the next SDK releases come out, when AWS's or Google's pages name 2026-10-21, and when langchain-anthropic allows anthropic 2.x. The same week in the Python ecosystem: LiteLLM 1.107.0 compromised on PyPI and Docker: what to do.

Frequently asked questions

Why is my Claude API request returning 400 for temperature?

Your request goes out with API version 2026-10-21, which rejects temperature, top_p, and top_k at any value. Python anthropic 2.0.0, TypeScript @anthropic-ai/sdk 1.0.0, and the other SDK majors released on October 21, 2026 send that version by default. Delete the parameter, or keep that request on 2023-06-01.

Can I still set temperature on Claude?

Only on API version 2023-06-01 (or, on Bedrock and Google Cloud, their own body version), and only on a model that accepts other values, such as Claude Sonnet 4.6. Claude 4.7 and later models return a 400 for a non-default value on every API version, and 2026-10-21 returns a 400 for any value on every model.

What is the default temperature on Claude?

1.0. Anthropic's migration guide says a request without the sampling parameters "samples with their defaults, including a temperature of 1.0, the same as a 2023-06-01 request that leaves them out."

Does Claude Opus 4.7 support temperature?

Not at a non-default value. Anthropic's model deprecations page says the API returns a 400 error when temperature, top_p, or top_k is "set to a non-default value on Claude 4.7 and later models", and on 2026-10-21 any value returns a 400.

How do I pin the Anthropic Python SDK?

Give it an upper bound below the next major: pip install "anthropic<2" keeps 1.x, which sends 2023-06-01, and anthropic>=2,<3 keeps 2.x. Without a bound, pip install -U anthropic installs the newest major: 2.x (2.3.0 at 08:38 JST on October 24).

What is anthropic-version?

The request header that names the Claude API version. Anthropic's versions page says you "must send an anthropic-version request header", and the SDKs set it for you. On Bedrock and Google Cloud's own endpoints, it's the anthropic_version field in the request body.

Does top_k still work?

Not on 2026-10-21, where top_k returns a 400 like temperature and top_p. On 2023-06-01 it works only on models that accept non-default sampling values, such as Claude Sonnet 4.6.

Is API version 2023-06-01 being removed?

Anthropic hasn't said. Its versions page and the migration guide give no end date for 2023-06-01, and the versions page says "Anthropic recommends using the latest API version whenever possible" (checked 08:36 JST on October 24).

What is the exact error message for temperature on 2026-10-21?

Anthropic hasn't published it. Its errors page lists the text of other 400 errors but not this one (checked 08:36 JST on October 24). The same page gives invalid_request_error as the type of a 400: "There was an issue with the format or content of your request."

Why does pip say langchain-anthropic requires anthropic<2.0.0?

langchain-anthropic 1.7.6 declares anthropic<2.0.0,>=0.120.0. When you run pip install -U anthropic, pip prints the conflict as an ERROR but installs the newest 2.x anyway, and ChatAnthropic then sends your temperature with 2026-10-21. Run pip install "anthropic<2" to go back to the last 1.x, 1.17.0.

Sources

Times are in JST (UTC+9), on October 24, 2026.