Claude API · Next.js ·

Claude ‘temperature is deprecated for this model’: the 400 error and the fix in Next.js

You switched a Next.js route to claude-sonnet-5-5 or claude-haiku-5-5, and every request now fails with a 400 about temperature. This post covers what the newer Claude models reject, what they still accept, why the two common Next.js SDKs behave differently, and a small helper that removes the parameters for the models Anthropic names.

If you want the next step, read Anthropic API 2026-10-21 broke my code: the fixes.

What we did and didn't test. We don't have an Anthropic API key and made no live API calls, so we haven't seen this 400 ourselves. Everything about what the API accepts or rejects is quoted from Anthropic's docs as of 24 Oct 2026 (listed in Sources); those pages change with each model launch, so check them before you rely on a detail here. What we did run, with TZ=UTC and a fake fetch so nothing left our machine: a check of what @anthropic-ai/sdk 0.135.0 and the Vercel AI SDK (ai 7.0.143 with @ai-sdk/anthropic 4.0.82) put in the request body, and the helper below, type-checked with TypeScript 5.9.3 in strict mode and covered by two unit tests. We aren't affiliated with or endorsed by Anthropic or Vercel; Claude and Claude Code are Anthropic's trademarks, and other product names belong to their owners; all are used here only to name those products.

Update, 24 Oct 2026: on API version 2026-10-21, even the defaults return a 400. Anthropic released API version 2026-10-21 on 21 Oct 2026, and the new SDK majors send it by default (for example anthropic 2.0.0 and @anthropic-ai/sdk 1.0.0). Anthropic's migration guide says: "In 2026-10-21, a request that sends temperature, top_p, or top_k returns a 400 error, even at the parameter's default value." So the "What still passes" section below applies only to requests on 2023-06-01. On 2026-10-21, leave all three out. We still have no API key, so this is quoted from the docs, not tested. For the version upgrade and the proxy changes that come with it, see Anthropic API 2026-10-21 broke my code: the fixes.

What the error means

In public reports, the error reads:

`temperature` is deprecated for this model.

We couldn't find that exact string on an Anthropic page, but it matches what the docs describe. Anthropic's model deprecations page says, as of 24 Oct 2026, that temperature, top_p, and top_k are removed in API version 2026-10-21, and: "Earlier API versions return it when set to a non-default value on Claude 4.7 and later models and Claude Mythos Preview."

There are reports on GitHub from projects running into it, for example a Dify plugins issue about Claude Haiku 5.5 on Bedrock and a Harbor issue about temperature still being sent to Claude Opus 5.

Which models reject it, and which still accept it

Our summary of Anthropic's docs as of 24 Oct 2026, for requests on API version 2023-06-01:

Which models reject it, and which still accept it
Model temperature, top_p, top_k Source
Claude Sonnet 5.5 Remove all three Sonnet 5.5 migration guide
Claude Haiku 5.5 Omit all three Haiku 5.5 migration guide
Claude 4.7 and later models A non-default value returns a 400 Model deprecations
Earlier models, such as Claude Sonnet 4.6 Other values accepted Migrating to API version 2026-10-21

The Sonnet 5.5 guide puts it this way: "Sampling parameters return an error. Remove temperature, top_p, and top_k."

The 7 Oct 2026 release notes say the same about Haiku: "Code written for Claude Haiku 4.5 can break on Claude Haiku 5.5. Manual extended thinking (budget_tokens), the sampling parameters temperature, top_p, and top_k, and assistant message prefill can each return a 400 error."

What still passes

This section applies to API version 2023-06-01. On 2026-10-21, sending any of the three parameters returns a 400, even at its default, per the update above.

Anthropic's current docs no longer list exact accepted values for each model. The model deprecations page says only that on earlier API versions the three parameters return a 400 when set to a non-default value on Claude 4.7 and later models and Claude Mythos Preview.

The simplest option the docs give is to leave all three out. The Haiku 5.5 guide says: "On Claude Haiku 5.5, omit temperature, top_p, and top_k and use prompting to guide the model's behavior instead."

Why you may be seeing it now

Anthropic's model deprecations page says: "On September 30, 2026, Anthropic notified developers using Claude Sonnet 4.5 of its upcoming retirement on the Claude API." As of 24 Oct 2026, it lists claude-sonnet-4-5-20250929 as retiring on 30 November 2026, with claude-sonnet-5-5 as the recommended replacement. If your code sets temperature: 0 and you switch to that replacement, this is the 400 you can expect.

A few related details from the same page:

  • Anthropic describes "providing at least 60 days' notice before model retirement for publicly released models."
  • The Haiku 4.5 row (claude-haiku-4-5-20251001) reads: Active, N/A, "Not sooner than October 15, 2026".
  • The dates are for Anthropic-operated platforms, including the Claude API: "Partner-operated platforms, Amazon Bedrock and Claude Models on Google Cloud (Google managed), set their own retirement schedules, so a model's lifecycle status and dates can differ."

The fix in Next.js

What each SDK sends

We ran the same call, with temperature: 0, through both SDKs against a fake fetch and looked at the request body. In the versions we tested:

What each SDK sends
SDK (version) Model ID temperature: 0 in the request?
@anthropic-ai/sdk 0.135.0 claude-sonnet-5-5 Sent
@ai-sdk/anthropic 4.0.82 claude-sonnet-5-5 Dropped, with a warning
@ai-sdk/anthropic 4.0.82 claude-haiku-5-5 Dropped, with a warning
@ai-sdk/anthropic 4.0.82 claude-sonnet-4-5-20250929 Sent
@ai-sdk/anthropic 4.0.82 claude-haiku-4-5-20251001 Sent

The Vercel AI SDK returned this in warnings for claude-sonnet-5-5:

{"type":"unsupported","feature":"temperature","details":"temperature is not supported by claude-sonnet-5-5 and will be ignored"}

So with the Vercel AI SDK, in these versions and for these two model IDs, the request goes out without temperature. With @anthropic-ai/sdk, it goes out as written, and per Anthropic's docs the API would return the 400. We didn't test other model IDs, and the Vercel AI SDK's model list can change in any release.

The @anthropic-ai/sdk type for temperature is marked deprecated, not removed. Its type file reads "@deprecated Deprecated. Models released after Claude Opus 4.6 do not support", and in our check tsc --strict still compiled temperature: 0 without an error. An editor may show it struck through, but the build won't stop you.

A small model-aware helper

If you call @anthropic-ai/sdk directly and still use older models for some routes, you can remove the sampling parameters for the models the docs name. The helper below also removes them for every model when your requests use API version 2026-10-21, because on that version even the defaults return a 400. It never sets them to a default value. The model-list version is the one we tested; the apiVersion check was added on 24 Oct 2026 and type-checked only.

// Models that Anthropic's migration guides say reject non-default sampling params.
// Add IDs only when Anthropic's docs name them.
const NO_SAMPLING = new Set(['claude-sonnet-5-5', 'claude-haiku-5-5']);

type Sampling = { temperature?: number; top_p?: number; top_k?: number };

// On API version 2026-10-21, temperature, top_p, and top_k return a 400 on every model,
// even at their defaults, so remove them for every model there.
export function stripSamplingParams<T extends Sampling>(
  model: string,
  params: T,
  apiVersion: '2023-06-01' | '2026-10-21' = '2023-06-01',
) {
  if (apiVersion !== '2026-10-21' && !NO_SAMPLING.has(model)) return params;
  const { temperature, top_p, top_k, ...rest } = params;
  return rest;
}

If you're on @anthropic-ai/sdk 1.0.0 or later, your requests use 2026-10-21, so pass '2026-10-21', or simply stop sending the three parameters.

Using it in a route handler:

const model = 'claude-sonnet-5-5';
await anthropic.messages.create({
  model,
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'hi' }],
  ...stripSamplingParams(model, { temperature: 0 }),
});

With our fake fetch, that request went out without temperature. The tests:

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { stripSamplingParams } from './sampling.js';

const p = { max_tokens: 16, temperature: 0, top_p: 0.9, top_k: 40 };

test('5.5 models drop all three', () => {
  for (const m of ['claude-sonnet-5-5', 'claude-haiku-5-5']) {
    assert.deepEqual(stripSamplingParams(m, p), { max_tokens: 16 });
  }
});

test('4.5 models keep them', () => {
  for (const m of ['claude-sonnet-4-5-20250929', 'claude-haiku-4-5-20251001']) {
    assert.deepEqual(stripSamplingParams(m, p), p);
  }
});

The helper drops all three parameters for the listed models, even an allowed temperature: 1, because leaving them out is what the guides recommend. On 2026-10-21 it drops them for every model. It only knows the two IDs in the set. The model deprecations page applies the non-default rule to Claude 4.7 and later models, so if you use another newer model, check its docs and add its ID.

“I set temperature 0 for consistent output”

Leaving temperature out does change output on models that still accept other values. Anthropic's migration guide for 2026-10-21 says: "On models that accept other values, such as Claude Sonnet 4.6, a request that lowered temperature for more consistent output loses that effect. No other setting replaces it."

On the newer models, the guides point to prompting instead: clear instructions and examples of the output you want. If you need a fixed shape, such as JSON for a parser, Anthropic's docs cover structured outputs. Check that page for which models support it.

Other things that can break when you move from Sonnet 4.5 to 5.5

A short checklist. Anthropic's Sonnet 5.5 migration guide has the full list.

  • Prefill. "Claude Sonnet 5.5 rejects a prefilled last assistant turn with a 400 error". The guide gives the message as:
This model does not support assistant message prefill. The conversation must end with a user message.
  • Manual extended thinking. The release notes list budget_tokens among the things that can return a 400 on Haiku 5.5. See the migration guides for what replaces it.
  • Token counts. The Sonnet 5.5 guide says "the same text produces about 30 percent more tokens, depending on the content." If you budget or cap by tokens, recount after the switch; our token counting guide covers the count endpoint.

For other Anthropic API errors, such as 429 and 529, see our rate limit error guide.

Building on Claude for your users? Check what each user can spend

A model switch, especially one that can raise token counts, is a reasonable moment to look at what each of your users can spend. Our per-user spend limits post shows the pattern in Next.js.


Sources (checked 24 October 2026):

Anthropic, Claude, and Claude Code are trademarks of Anthropic. Next.js and Vercel are trademarks of Vercel Inc. TypeScript is a trademark of Microsoft. GitHub is a trademark of GitHub, Inc. Amazon Bedrock is a trademark of Amazon.com, Inc. or its affiliates. Google Cloud is a trademark of Google LLC. Other names belong to their owners. Names are used only to identify products and compatibility. Stack & Ship is not affiliated with or endorsed by any of them.

Disclosure: this is our own paid product.

The Claude API 2026-10-21 Upgrade Kit has a scanner designed to flag the code and proxy settings that break when you move to API version 2026-10-21, which you run locally or in CI. It also has a rules block so a coding agent stops re-adding removed parameters, and the kit sends nothing to us.

Get the Claude API 2026-10-21 Upgrade Kit for $9 (plus VAT where applicable).