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.
This guide pairs with Spend Caps Kit, and if you want the next step, read Prompt caching not working? Check it in OpenAI and Anthropic (Next.js).
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 17 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.
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 Messages API reference says, as of 17 Oct 2026: "Models released after Claude Opus 4.6 do not support setting temperature. A value of 1.0 will be accepted for backwards compatibility, all other values will be rejected with a 400 error."
There are open reports on GitHub from projects running into it, for example here and here.
Which models reject it, and which still accept it
Our summary of Anthropic's docs as of 17 Oct 2026:
| Model | temperature |
top_p |
top_k |
Source |
|---|---|---|---|---|
| Claude Sonnet 5.5 | Only the default | Only the default | Rejected | Sonnet 5.5 migration guide |
| Claude Haiku 5.5 | Only 1 |
Only 0.99 |
Rejected | Haiku 5.5 migration guide |
| Models released after Claude Opus 4.6 | Only 1.0 |
0.99 or more | Rejected | Messages API reference |
| Claude Sonnet 4.6 and earlier, Claude Haiku 4.5 | Accepted | Accepted | Accepted | Sonnet 5.5 migration guide |
The Sonnet 5.5 guide puts it this way: "Claude Sonnet 4.6 and earlier models and Claude Haiku 4.5 accept temperature, top_p, and top_k. On Claude Sonnet 5.5, a non-default value returns a 400 error. Remove them."
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
The Haiku 5.5 guide gives the exact values:
- "If a request includes
temperature, it must be1. If it includestop_p, it must be0.99, its default." - "Any other
temperatureortop_pvalue returns a 400 error, including atop_pof1. So does anytop_kvalue, and so does a request that includes bothtemperatureandtop_p."
For models released after Claude Opus 4.6 in general, the API reference adds that for top_p "A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error." and that those models "do not accept top_k; any value will be rejected with a 400 error."
The simplest option the docs give is to leave all three out. The Haiku 5.5 guide says: "On Claude Haiku 5.5, omit all three 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 17 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 the Claude API: "Partner-operated platforms (Amazon Bedrock and Google Cloud) 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:
| 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 only for the models the docs name. This is the helper we tested:
// 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 };
export function stripSamplingParams<T extends Sampling>(model: string, params: T) {
if (!NO_SAMPLING.has(model)) return params;
const { temperature, top_p, top_k, ...rest } = params;
return rest;
}
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. It only knows the two IDs in the set. The API reference applies the same rules to every model released after Claude Opus 4.6, so if you use another newer model, check its docs and add its ID.
"I set temperature 0 for consistent output"
Even before this change, temperature: 0 didn't make output fully repeatable. The API reference says: "Note that even with temperature of 0.0, the results will not be fully deterministic."
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_tokensamong 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% 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.
Disclosure: this is our own paid product. If your Next.js app calls Claude for your users, the Spend Caps Kit is designed to add per-user rate limits and a monthly dollar cap per user. It does not fix or detect the temperature 400 or any other API parameter error. It does not change which parameters Anthropic models accept. It does not replace Anthropic Console spend limits. It costs $19 (plus VAT where applicable).
Sources (checked 17 October 2026):