Skip to content
Nilay Kabariya

Entry No.060·AI·Updated ·4 min read

Claude "temperature is deprecated for this model" (400)

Switching to Claude Sonnet 5.5, Haiku 5.5 or Opus 4.7 breaks code that sets temperature, even temperature: 0. Every case tested, in Node and Python.

The error, verbatim

Jump to the fix ↓
BadRequestError: 400 {"type":"error","error":{"type":"invalid_request_error","message":"`temperature` is deprecated for this model."}}

Tested on

@anthropic-ai/sdk
0.133.0; 1.6.0 (November 7)
anthropic (Python)
1.13.0
Models
Sonnet 5.5, Haiku 5.5, Opus 4.7, Opus 4.6, Haiku 4.5
Date
October 11, 2026; API version 2026-10-21 re-tested November 7
Contents
  1. Which values fail, on which models01
  2. The fix02
  3. Python: a TypeError before the request is even sent03
  4. Since October 21: the API rejects it on every model04
  5. Sonnet 4.5 may already be gone for you05
  6. How this was tested06

Your request worked on an older Claude model. You change the model name and get a 400 about a parameter you’ve been sending for months. This is going to hit a lot of people soon: Claude Sonnet 4.5 retires on November 30, 2026, and Anthropic’s recommended replacement, claude-sonnet-5-5, is one of the models that rejects it.

I sent the same one-word request to six Claude models with each sampling parameter set, in Node and in Python. The rule turned out to be sharper than “temperature is deprecated”.

Which values fail, on which models

Request Sonnet 5.5, Haiku 5.5, Opus 4.7 Opus 4.6, Haiku 4.5
no sampling parameters ✅ works ✅ works
temperature: 1 ✅ works ✅ works
temperature: 0.2 ❌ 400 ✅ works
temperature: 0 ❌ 400 ✅ works
top_p: 0.9 ❌ 400: `top_p` is deprecated for this model. ✅ works
top_k: 40 ❌ 400: `top_k` is deprecated for this model. ✅ works
temperature and top_p together ❌ 400 ❌ 400: `temperature` and `top_p` cannot both be specified for this model. Please use only one.

Two things stand out:

  • temperature: 0 is rejected. That’s the value people set on purpose, for repeatable output, so it’s exactly the code that breaks. Only 1 gets through, because it’s the default.
  • The older models have their own trap. Opus 4.6 and Haiku 4.5 accept each parameter on its own, but not temperature and top_p together. Code that sets both already fails there.

The error is an invalid_request_error, in Node a BadRequestError with status 400. It names the first parameter it rejects, so after you remove temperature you may get the same message for top_p.

The fix

On Sonnet 5.5, Haiku 5.5 and Opus 4.7, remove temperature, top_p and top_k from the request:

const msg = await client.messages.create({
  model: 'claude-sonnet-5-5',
  max_tokens: 1024,
  // temperature: 0,   <- delete
  // top_p: 0.9,       <- delete
  messages: [{ role: 'user', content: 'Hello' }],
});

Anthropic’s own advice for these models is to steer the output with your prompt instead of sampling parameters. If several of your requests share one helper, remove the parameters there, or make them conditional on the model:

const legacy = ['claude-opus-4-6', 'claude-haiku-4-5-20251001'];
const sampling = legacy.includes(model) ? { temperature: 0 } : {};
await client.messages.create({ model, max_tokens: 1024, messages, ...sampling });

Python: a TypeError before the request is even sent

The Python SDK went further. Since anthropic 1.0.0 (I checked 1.0.0 through 1.17.0 and 2.1.0), temperature, top_p and top_k are gone from messages.create() entirely, so the error comes from Python itself, for every model, including the ones that still accept it:

TypeError: Messages.create() got an unexpected keyword argument 'temperature'

So upgrading the Python SDK breaks code that ran fine against Haiku 4.5 or Opus 4.6, before you’ve changed any model name.

For the new models, remove the argument, as above. If you need temperature on an older model that still supports it, pass it through extra_body:

msg = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
    extra_body={"temperature": 0.2},
)

Since October 21: the API rejects it on every model

On October 21, 2026, Anthropic released API version 2026-10-21, and the new SDKs (anthropic 2.0.0 for Python, @anthropic-ai/sdk 1.0.0 for TypeScript) send it by default. Anthropic’s migration guide says a 2026-10-21 request with temperature, top_p or top_k returns a 400 on any model, even at the default value. So the extra_body bridge above stops working once you upgrade.

I tested that on November 7 with @anthropic-ai/sdk 1.6.0, which sent anthropic-version: 2026-10-21. temperature: 0 and temperature: 1 both failed on Haiku 4.5 as well as Haiku 5.5, with a different message from the one at the top of this page (status and message as the SDK reported them):

400 temperature: Extra inputs are not permitted

On Python 2.1.0, one request can still be kept on the old API version, where older models take the parameter. That line and the other SDK 2.0 errors, with tests, are in unexpected keyword argument temperature, betas.

Sonnet 4.5 may already be gone for you

Anthropic lists claude-sonnet-4-5-20250929 as deprecated, retiring November 30. With my API key it was already unavailable on October 11. Every call returned:

NotFoundError: 404 {"type":"error","error":{"type":"not_found_error","message":"model: claude-sonnet-4-5-20250929"}}

The Node SDK also printed its own warning before each call: Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information. If you see that line in your logs, the model in your code is on the retirement list.

My key belongs to a newer organization, which may never have had Sonnet 4.5. Anthropic’s page says requests fail after the retirement date, so an account that has been using it should keep it until then. Either way, the replacement is Sonnet 5.5, and moving to it is when the temperature error appears.

How this was tested

Six models (claude-sonnet-4-5-20250929, claude-sonnet-5-5, claude-haiku-4-5-20251001, claude-haiku-5-5, claude-opus-4-6, claude-opus-4-7), each called with no sampling parameters, temperature 0, 0.2 and 1, top_p 0.9, top_k 40, and temperature with top_p. Node used @anthropic-ai/sdk 0.133.0 on Node 24, Python used anthropic 1.13.0 on Python 3.13, both on October 11, 2026. Every request asked for a single output token. The retirement date and replacement are from Anthropic’s model deprecations page.

— N.K., end of entry No.060

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.059

    OpenAI Oct 23 model shutdown: the 404, list, replacements

    gpt-3.5-turbo, gpt-4, o1, o3-mini and more stopped working on October 23, 2026. The real error, tested after the shutdown, and a check that misleads.

    > NotFoundError: 404 The model `gpt-3.5-turbo` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations

    AI4 min
  2. No.087

    Claude SDK: unexpected keyword argument temperature, betas

    Messages.create() got an unexpected keyword argument after an anthropic upgrade, plus what SDK 2.0 (October 21) breaks next. Python and TypeScript, tested.

    > TypeError: Messages.create() got an unexpected keyword argument 'temperature'

    AI4 min
  3. No.088

    Responses.create() unexpected keyword argument: new names

    max_tokens, messages, response_format, seed: their names in OpenAI's Responses API, tested. Plus the 'proxies' TypeError from httpx 0.28.

    > TypeError: Responses.create() got an unexpected keyword argument 'max_tokens'

    AI6 min
  4. No.022

    Fix: Could not resolve authentication method (Anthropic / Claude SDK)

    Anthropic's SDK can't find your key. The old and new wording, ANTHROPIC_API_KEY vs ANTHROPIC_AUTH_TOKEN, and the 401 you get when a key is in the wrong one.

    > Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.

    AI4 min

Post card · Every Sunday

What broke this week.

One email on Sundays: the Node, TypeScript, Python and AI SDK releases that broke builds that week, each one reproduced, with a link to the fix that worked. Never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text