If the Claude API returns the following error, the cause is that you are sending a non-default value for temperature (or top_p or top_k) to a Claude 4.7 or later model. The fix is to remove these three parameters from your requests. In the new API version 2026-10-21, released in October 2026, sending any of them returns a 400 error for every model, regardless of the value.

400 invalid_request_error
`temperature` is deprecated for this model.

Example of a response when a non-default value is sent to a Claude 4.7 or later model (reported by users). The official documentation does not say whether the error message returned by the new API version is the same.

How to fix it: remove the three parameters

Causes a 400 error

client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    temperature=0.2,
    messages=[...],
)

After the fix

client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[...],
)

To change the format or tone of answers, give instructions in the prompt rather than through parameters (recommended in Anthropic's migration guide).

Based on Anthropic's official documentation (checked October 26, 2026), this article explains the two situations where this error appears, what happens when you update the SDK, the changes to make together with the new API version, and how to fix the similar error anthropic-version: header is required. API versions are color-coded: 2023-06-01 (the previous version) and 2026-10-21 (the new version).

1. The two situations where the error appears

The Claude API selects the API version with the anthropic-version request header. Whether you get an error depends on the combination of the model you use and the API version.

Model2023-06-012026-10-21
Claude 4.7 and later modelsOpus 4.7 and models released after it (for example, Opus 5, Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1)400 if a non-default value is sentWorks if you send the default value or send nothing400 if sent400 even with the default value
Earlier modelsClaude Sonnet 4.6 and othersWorksYou can lower the value to reduce variation in answers400 if sent400 even with the default value

Sources: Anthropic, "Migrating to API version 2026-10-21" (Claude 4.7 and later models accept only the default value; Sonnet 4.6 and others accept other values; under 2026-10-21, every model returns 400 even with the default value), and the migration guides for each model (Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1; the Fable 5.1 guide says it has the same sampling restrictions as Opus 5). Checked October 26, 2026.

The cells marked "400" in the table correspond to the following two situations.

  1. Situation 1: You sent a non-default value with 2023-06-01 to a Claude 4.7 or later model (first row of the table, 2023-06-01 column)
  2. Situation 2: You sent any of the three with 2026-10-21, regardless of model or value (the right-hand column of the table)

The error message at the top, `temperature` is deprecated for this model., appears in situation 1 in an API response that a user reported on GitHub (reported example). Anthropic's official documentation does not include the error message itself; it only says that the request returns a 400 error.

In short, removing the three parameters fixes both situations. If you were changing values on an older model, note that removing them will change how much answers vary (see Section 2).

2. The fix, and how to get the same answer every time

  1. Remove the three parameters from your requestsRemove temperature, top_p, and top_k from Messages API requests and from each request in Message Batches. If a configuration file or wrapper function sets a default value for them, remove it there too.
  2. What happens after removalIf you don't send the three, the default values are used to choose the next token (temperature defaults to 1.0). The default values for top_p and top_k are not given as numbers, so not sending them is the safest choice. This is the same as not sending the three with earlier API versions. Claude 4.7 and later models accept only default values from the start, so their behavior does not change.
  3. If you want the same answer every timeThere is no setting that replaces it. Anthropic's migration guide recommends guiding model behavior with prompts. It also says that even with temperature = 0, there was never a guarantee of identical answers on earlier models. If you only want to standardize the answer format, you can use Structured outputs, which lets you define a JSON shape and have the model return it.

The exception is when you used a model that accepts other values, such as Claude Sonnet 4.6, and lowered the value to reduce variation in answers. With the new API version you have to remove it, and that effect is lost. Anthropic's guidance is either to keep that request on 2023-06-01 or to stop sending the parameter. To keep 2023-06-01, either stay on the current major version of the SDK (1.x for Python), or, if you call HTTP directly, keep the header as anthropic-version: 2023-06-01. The migration guide does not explain how to choose an older API version per request with the new SDK.

How to fix it in TypeScript and HTTP

// TypeScript (@anthropic-ai/sdk): remove temperature
const msg = await client.messages.create({
  model: "claude-sonnet-5-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello, Claude" }],
});
# HTTP (JSON body): leave out the temperature, top_p, and top_k lines
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "messages": [{"role": "user", "content": "Hello, Claude"}]
}

3. Finding where your code sends the parameters

If you don't know where the error comes from, search your code for the names of the three parameters. Even if you didn't write it yourself, default values are often set in configuration files, shared functions, or environment variables.

# macOS, Linux, WSL: search the project (case-insensitive)
grep -rniE "temperature|top_p|top_k" --exclude-dir={node_modules,.venv,venv,.git,dist} \
  --include="*.py" --include="*.ts" --include="*.js" --include="*.json" \
  --include="*.yaml" --include="*.yml" --include="*.toml" --include=".env*" .

# Windows (PowerShell)
Get-ChildItem -Recurse -Include *.py,*.ts,*.js,*.json,*.yaml,*.yml,*.toml,.env* |
  Where-Object { $_.FullName -notmatch "node_modules|\\.?venv|\\.git\\|\\dist\\" } |
  Select-String -Pattern "temperature|top_p|top_k"
Where it was foundHow to fix
Line that calls the APIRemove the three from the arguments
Shared function or wrapperRemove where it is set as a default (also check whether callers pass values)
Configuration file or environment variableRemove the entry, or check that an empty value does not get included in the request
Message Batches requestsAlso remove from the params of each request (each request in a batch returns 400)
Token counting requestsAlso remove from the body sent to /v1/messages/count_tokens
Through a third-party libraryCheck the library's documentation to see whether it has a setting that sends temperature to Claude

The new API version rules apply to Messages API requests, token counting requests, and each Message Batches request (Anthropic's migration guide).

4. What happens when you update the SDK

Official SDKs automatically send the API version that was current when their major version was released. Starting with the SDK versions in the table below, they send 2026-10-21, and the three removed parameters are also gone from the SDK types (Anthropic's migration guide). So when you update the SDK, you may see the problem first as a type-checking error or an "unexpected argument" error rather than as a 400 from the API. If you add parameters to the body without going through the types (for example, using a feature that passes extra body fields, or sending requests directly over HTTP), the API returns a 400. The fix is the same in both cases: remove the three parameters.

Language or toolFirst version that sends 2026-10-21
Pythonanthropic 2.0.0
TypeScript@anthropic-ai/sdk 1.0.0Also update the related packages for Bedrock, Vertex, and Foundry to v1
Javacom.anthropic:anthropic-java 3.0.0
Goanthropic-sdk-go 2.0.0The module path is github.com/anthropics/anthropic-sdk-go/v2
C#Anthropic 13.0.0
Rubyanthropic 2.0.0
PHPanthropic-ai/sdk 1.0.0
CLIant 2.0.0

Source: Anthropic, "Migrating to API version 2026-10-21," Upgrade steps. If you call the API without an SDK, set the anthropic-version header to 2026-10-21 to use the new API version.

The new API version is available on the Claude API, Claude Platform on AWS, Claude on Google Cloud (both Anthropic-managed and Google-managed), and Microsoft Foundry. On Amazon Bedrock, the new version is available only for Claude 4.7 and later models. If you call older models there, Anthropic advises keeping your current SDK version (or your current anthropic-version) (Versions).

Steps for updating the SDK

  1. Switch to the new API versionUpdate the SDK to the version in the table above. If you call HTTP directly, set anthropic-version: 2026-10-21.
  2. Fix the breaking changesRemove the three parameters and fix the items in the table in Section 5 that apply to you. Also check the changes in how new SDKs are written (such as type names) under "SDK and CLI changes" in the migration guide.
  3. Test against the new API version before releaseBefore you go to production, test that your requests succeed with the new API version. Release the SDK update and the fixes together.

Source: Anthropic, "Migrating to API version 2026-10-21," Upgrade steps (Switch to 2026-10-21 → Update your code for the breaking changes → Test against 2026-10-21).

5. Other changes to fix with the new API version

If you move to the new API version, there are other changes besides temperature. (The API key row is a change in the SDK and CLI only; it does not matter if you call HTTP directly.) Fix only the ones that apply to you (Breaking changes in the same migration guide).

What changesWhat changes exactlyHow to fix
Documents in assistant messages400 errorSend documents in user messages
Citations in user message textSending non-empty citations returns a 400Remove those citations (citations in assistant messages still work as before)
How the API key is sentChange in the SDK and CLI (the API accepts either header)Sent with Authorization: Bearer instead of X-Api-KeyUpdate proxies, gateways, and log filters that read the key so they use Authorization (the API accepts either header)
Admin API field namesFor example, the workspace_id field on API keys is removedRead the new names, such as scope.workspace_id

The following error appears when a request has no API version header.

400 invalid_request_error
anthropic-version: header is required

Official SDKs send the API version automatically, so this mainly appears when you call HTTP directly without an SDK. For example, GitHub reports describe it happening when someone points a client or tool built for OpenAI at the Claude API URL and tries to list models (/v1/models) (Example 1, Example 2).

The fix is to add the header. For new code, specify 2026-10-21. To get existing code working without changes, specify 2023-06-01.

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -H "content-type: application/json" \
  -d '{"model": "claude-opus-5-5", "max_tokens": 1024,
       "messages": [{"role": "user", "content": "Hello, Claude"}]}'

Source: Anthropic, "Versions" (the anthropic-version header is required in requests; SDKs send it automatically). The error message is from an API response that a user reported on GitHub. The API accepts the API key in either the x-api-key or the Authorization: Bearer header (migration guide).

If the tool you use does not let you add headers, check whether that tool supports the Claude API (and whether it is calling the API as if it used OpenAI's format).

Summary

  • `temperature` is deprecated for this model. is the 400 error returned when a non-default value of temperature, top_p, or top_k is sent to a Claude 4.7 or later model. Removing the three parameters fixes it.
  • In the new API version 2026-10-21, sending the same three returns a 400 regardless of value or model (the error message is not published in the official documentation).
  • Newer SDKs such as Python's anthropic 2.0.0 send 2026-10-21 automatically, and the three arguments are also removed from the types. Code that still passes them gets an argument error or a 400 after the SDK update.
  • There is no setting that guarantees the same answer every time. Use prompts for instructions (you can standardize the answer format with Structured outputs).
  • anthropic-version: header is required means the API version header is missing. It occurs when you call the API without an SDK.

FAQ

Q. Can I send temperature set to 1.0 (the default value)?

With the new API version 2026-10-21, sending it returns a 400 even with the default value. If you call a Claude 4.7 or later model with 2023-06-01, the default value works, but there is no point in sending it, so removing it is the safest option.

Q. I used temperature = 0 to get the same answer every time. What should I use instead?

There is no setting that replaces it. Anthropic's migration guide says that even temperature = 0 never guaranteed the same answer. If you want to standardize the answer format (such as JSON fields), use Structured outputs, and specify wording and decision criteria in detail in the prompt.

Q. Can I keep using the current version without moving to the new API version?

Yes. Anthropic says it keeps existing input and output fields within each API version, and 2023-06-01 can still be specified as before. The Versions page does not say when 2023-06-01 will be retired (Versions, checked October 26, 2026). However, for Claude 4.7 and later models, a non-default temperature or similar value still returns a 400 even with 2023-06-01. Anthropic also recommends using the newer API version where possible, and updating the SDK switches you to the new version automatically.

Q. I switched to a Claude 4.7 or later model and got an error

After switching to a Claude 4.7 or later model, a non-default temperature or similar value returns a 400 even if the API version stays the same. For other points to fix when changing models (such as thinking settings and prefilling), see "Claude Opus 4.7 migration guide."