Claude API 2026-10-21: temperature, top_p and top_k are gone
In Claude API version 2026-10-21, a request that sends temperature, top_p or top_k fails with a 400 error, even at the default value. Who it breaks, why Claude 4.7 and later models already worked this way, what replaces a low temperature, and the other 3 changes to check before your SDK upgrade.
Tecyfy · Published · 6 min read

In Claude API version 2026-10-21, a request that sends temperature, top_p or top_k fails with a 400 error, even when the value is the default. Remove the 3 parameters from your requests before you move to that version. Without them, Claude samples at the defaults, a temperature of 1.0, and for Claude 4.7 and every later model nothing about the output changes.
The change reaches most teams through an upgrade rather than a decision. A Claude SDK sends the API version that was current when its major version came out, so the next major upgrade of the Python or TypeScript SDK moves every request to 2026-10-21 at once. Code that sets temperature=0 will stop working on the day the dependency is bumped.
Who it breaks, and who it does not
It depends on 2 things: the API version the request sends, and the model.
- Claude 4.7 and later (including Opus 5.5, Sonnet 5.5 and Haiku 5.5) already accepted only the default values on the old version, 2023-06-01. If your code runs on these models today, it sends no sampling values or sends the defaults. Under 2026-10-21, even the default is an error, so delete the lines and the output stays the same.
- Older models that accepted other values, such as Claude Sonnet 4.6, are where the change bites. A request that set
temperature: 0.2for steadier output works on 2023-06-01 and fails on 2026-10-21. Removing the parameter makes it work again, at temperature 1.0, so the steadiness is gone and Anthropic says plainly that no other setting replaces it. - Requests with no sampling parameters are not affected by this part at all.
The same rule covers token counting and every request inside a Message Batch created with the new version.
Try your own request:
Request
POST /v1/messages anthropic-version: { "model": "claude-sonnet-4-6", "temperature": 0.2, "max_tokens": 1024, "messages": [ { "role": "user", … } ] }
400 error: 1 problem. Fix: temperature is not accepted in 2026-10-21, even at any value.
Rules from Anthropic's migration guide for API version 2026-10-21 and its deprecations page. The error wording here is ours; the API's own message differs. An SDK picks its API version by its major version, so upgrading the SDK changes the version for you.
Why the parameters went
TemperatureTemperatureA setting that controls how much chance goes into each word a model picks. Low gives focused, predictable answers; high gives more varied ones. scales how the model picks each next TokenTokenThe small piece of text a language model reads and writes, often part of a word. Prices, limits and the context window are all counted in tokens.: low values favour the likeliest token, high values spread the choice. top_p and top_k cut the list of candidates before the pick. Anthropic first locked all 3 to their defaults on Claude 4.7 and later, then removed them from the request format and from the SDKs' types in the new API version, with one recommendation in their place: guide the model with the prompt.
That is a change in habit: consistency now comes from what you ask and how you check the answer, not from a number in the request.
What to use instead of a low temperature
Teams set temperature low for 3 reasons, and each has a better tool now.
- The output has to fit a format. Use structured outputsStructured OutputA setting that makes a model's answer follow a JSON schema you give it, so your code can read fields such as a category or an order number without parsing free text., so the reply matches a JSON schema every time, or a tool definition the model fills in. A schema guarantees the shape. Temperature only made a wrong shape less likely.
- The same input should give the same answer. Write the rules down. Give the exact categories, a few worked examples and what to do when unsure, in the system promptSystem PromptInstructions the builder of an AI app gives the model before you type anything. It sets the role, the tone and the rules, and it outranks what users say.. Most variation at temperature 1.0 comes from instructions that leave room for it.
- You want to know it still works. Keep a set of real inputs with the answers you expect and run it after every prompt or model change. An eval measures consistency; a low temperature only hoped for it. How to evaluate an AI agent shows how to build one, and our eval sample size calculator says how many questions tell a real change from noise.
If a request on Sonnet 4.6 truly depends on a low temperature and you cannot test a replacement yet, the guide allows one way out: keep that request on 2023-06-01 while the rest of the code moves. Treat it as temporary: Anthropic retires older models on a published schedule, and every model from Claude 4.7 on accepts only the defaults.
The other changes in 2026-10-21
Sampling is the change most people will hit, but the same version has 3 more that return errors or change fields:
| Change | Affects you if | What to do |
|---|---|---|
A document block directly in an assistant message returns 400 | You put documents in the assistant turn | Send documents in a user message |
citations on text blocks in a user message return 400 | You send back cited text as user content | Remove citations there; citations on assistant turns are fine |
| Admin and Enterprise Analytics APIs drop the old names of renamed fields | Your scripts read roles, group_id, workspace_id on keys and others | Read the new names; API keys report scope |
The new SDK major versions also send the API key as Authorization: Bearer instead of in the X-Api-Key header. The API accepts both, but a proxy or gateway that reads X-Api-Key will see no key. Check that before you upgrade, not after.
How to move, in order
- Search your code for
temperature,top_pandtop_kin every call to Claude, including batch jobs, eval scripts and any wrapper library that sets them for you. - Delete them where the model is Claude 4.7 or later. Nothing changes in the output.
- For older models with a non-default value, replace the setting with a format, examples and an eval, then delete it. Our LLM API module covers the request shape if you are starting fresh.
- Check the other 3 changes in the table above.
- Upgrade the SDK to its new major version, or set the
anthropic-versionheader to2026-10-21if you call the API directly, and run your tests before you release.
Questions
- Does the Claude API still support temperature?
- Not in API version 2026-10-21. A Messages request that sends temperature, top_p or top_k returns a 400 error, even at the parameter's default value. On the older version, 2023-06-01, the parameters still exist, but Claude 4.7 and later models already reject any non-default value. Requests that leave them out sample at the defaults, including a temperature of 1.0.
- Why does my Claude API request return a 400 error about temperature?
- Either your request uses API version 2026-10-21, which rejects temperature, top_p and top_k at any value, or it uses 2023-06-01 with a non-default value on Claude 4.7 or a later model, which accepts only the defaults. Remove the parameters from the request. If you upgraded the SDK to a new major version, it now sends 2026-10-21 for you.
- What replaces temperature 0 on Claude?
- Nothing replaces it as a setting. Anthropic recommends leaving the parameter out and guiding the model with the prompt. For repeatable output, give exact instructions and examples, ask for a fixed format or use structured outputs so the shape is guaranteed, and test the prompt on a set of real inputs. On Claude Sonnet 4.6 and other models that accepted a lower value, you can keep a request on API version 2023-06-01 while you move.
- What else changed in Claude API version 2026-10-21?
- In the Messages API, a document block placed directly in an assistant message and citations on text blocks in a user message now return a 400 error. In the Admin and Enterprise Analytics APIs, renamed fields lose their old names, and API keys report a scope instead of workspace_id. The new SDK major versions also send the API key in the Authorization header, which matters to proxies that read X-Api-Key.
Sources