Claude API requests that set temperature, top_p, or top_k started returning a 400 error because Anthropic removed all three sampling parameters from the Messages API in version 2026-10-21. Sending any of them now fails the request, even if the value you send matches the model’s own default. The fix is either to stop sending the three parameters, which means every request samples at the model’s default (a temperature of 1.0), or to keep the affected calls on the older 2023-06-01 header if custom sampling still matters for them.
What actually changed in version 2026-10-21
Anthropic ships API versions as dated snapshots, and anthropic-version: 2026-10-21 is the first one to touch sampling controls. Anthropic’s own migration guide lists the change under breaking changes to the Messages API: “temperature, top_p, top_k are removed. Sending any of them returns 400, even at default values. Without them, sampling uses defaults, including temperature of 1.0.” That line does more than deprecate the parameters — it rejects the request outright, and it rejects it even when the value sent is exactly what the model would have used anyway.
The same release touches two other things worth knowing about even if they don’t break your code today: document blocks are no longer accepted inside assistant messages (move them to a user message instead), and citations fields on text blocks inside user messages also return 400 now — a change we cover in more detail in our piece on Claude’s Citations API. If your integration touches document blocks, citations, or sampling, budget time to test against 2026-10-21 in staging before flipping the header in production.
Why you won’t get an error message that names the parameter
Anthropic’s migration guide doesn’t publish the literal error body for this specific case, so don’t expect a message that spells out “temperature is no longer supported” in plain English. Based on how the Messages API reports other rejected-parameter cases — which we catalogued in our field guide to Claude API error codes — the shape to expect is a 400 response with type: invalid_request_error and a message naming the offending field inside a standard error object. If your error handling only checks the HTTP status code and retries on anything in the 4xx range, this failure looks identical to a malformed prompt or an expired key until someone actually reads the response body.
Fix 1: strip the parameters from the request
If you don’t have a hard requirement for custom sampling, the fastest fix is to delete the three keys and let the request fall through to the model’s defaults. Here’s the shape of the change for a direct HTTP call:
# Before (worked on 2023-06-01) — rejected on 2026-10-21
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-sonnet-4-6",
"max_tokens": 1024,
"temperature": 0.2,
"top_p": 0.9,
"messages": [{"role": "user", "content": "Summarize this ticket."}]
}'
# After — passes on 2026-10-21
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-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Summarize this ticket."}]
}'
Each deleted line matters for a specific reason. temperature and top_p are gone because the migration guide marks both as rejected regardless of the value sent, not just invalid ranges. top_k is gone for the same reason, even though it was never part of every SDK’s typed request interface, so teams that only ever set temperature by hand can still break if a shared request-builder function injects top_k by default somewhere upstream. The header itself, anthropic-version: 2026-10-21, is what triggers the new validation — the identical request body with an older header keeps working, which is the second fix below.
Fix 2: stay on 2023-06-01 where custom sampling is load-bearing
Some workloads genuinely need sampling control — a classification prompt tuned at a low temperature to cut down on variance, for instance. Anthropic’s guide is explicit that this is a supported path: keep those specific requests on anthropic-version: 2023-06-01 instead of upgrading the whole integration at once. That also means the version header doesn’t need to be a single global constant in your codebase. A thin wrapper that sets the header per request type, rather than per client instance, lets most traffic move to 2026-10-21 while a small, deliberate set of calls keeps the older header and its sampling controls.
One constraint to check before doing that: the guide notes that on Amazon Bedrock, 2026-10-21 is available only for Claude 4.7 and later models — a split Anthropic’s own Bedrock documentation also draws between Opus 4.7-and-later and Opus 4.6-and-earlier integration paths. A Bedrock deployment running an older model doesn’t get a choice yet; it stays on the prior version until the model itself is upgraded. Direct API access isn’t called out with the same restriction in the guide, so check your own account’s model availability rather than assuming every platform behaves the same way.
A safer rollout than flipping the header everywhere at once
Canarying this change by request type catches problems faster than canarying it by traffic percentage. A percentage-based rollout can run for hours before a low-volume but important call path — a nightly batch job, an admin-only report generator — happens to fire and fails. Grouping your Claude calls by the code path that issues them, then moving one path at a time to 2026-10-21 starting with the highest-volume, lowest-risk path, surfaces a broken request within the first few calls instead of the first few hours. Log the anthropic-version header alongside the response status for each call during the rollout; when a path fails, you’ll immediately see which version it was running, instead of having to reconstruct it from a deploy timeline.
Old behavior vs. new behavior
| Request includes | On 2023-06-01 | On 2026-10-21 |
|---|---|---|
temperature (any value) | Accepted and applied | 400 invalid_request_error |
top_p (any value) | Accepted and applied | 400 invalid_request_error |
top_k (any value) | Accepted and applied | 400 invalid_request_error |
| No sampling parameters set | Uses model default | Uses model default (temperature 1.0) |
| Bedrock, model below Claude 4.7 | Supported | Version unavailable until the model is upgraded |
A short checklist before you flip the header
- Grep your codebase and any shared prompt-builder utilities for
temperature,top_p, andtop_k— including values injected by a default-parameters object that individual call sites never explicitly override. - If you’re on the Python SDK, upgrade
anthropicto 2.0.0 or later; earlier SDK versions weren’t built against this version string and may not send it correctly. - Check whether you also send
documentblocks inside assistant messages orcitationson user-message text blocks — both break under the same version bump, separately from sampling. - If you call the Admin API, re-read the field renames shipped in the same release (
roles→role_ids,workspace_id→scope, and a few others) before you touch those endpoints on the new version. - Confirm your Bedrock models are on Claude 4.7 or later before moving Bedrock traffic to
2026-10-21. - Log the full response body, not just the status code, for at least the first week after rollout, so a rare call path that still sends a sampling parameter shows up quickly instead of silently retrying into a failure loop.
If low-temperature output was doing real work for you
Teams that relied on temperature: 0 or similar settings to get more consistent output have a real decision to make, not just a find-and-replace. Our piece on Claude’s model deprecation policy covers how Anthropic schedules changes like this one and how much notice teams typically get, which is useful context for deciding whether to keep calls pinned to 2023-06-01 long-term or treat it as a temporary bridge. If consistency, not creativity, was the actual goal behind a low temperature, a structured output schema constrains the shape of an answer more reliably than sampling ever did — we walk through the trade-offs in our checklist for choosing between structured output modes. And if the deeper motivation was cutting repeated work rather than reducing variance, prompt caching breakpoints solve a different problem than temperature ever did, but they’re worth knowing about while you’re already auditing this part of your integration.
FAQ
Does this affect the Claude.ai web app or only the API? The migration guide describes Messages API behavior specifically. It doesn’t mention the consumer Claude.ai interface, which exposes its own separate controls, so treat this as an API-only change unless Anthropic documents otherwise.
Does Vertex AI have the same Bedrock restriction? Anthropic’s guide calls out the Claude 4.7-and-later requirement for Bedrock specifically and doesn’t mention Vertex AI in that section. Don’t assume the same limit applies there — check your Vertex model list before switching a Vertex-based integration to the new version.
Is there a beta header that restores the parameters? The migration guide doesn’t mention a beta flag that brings temperature, top_p, or top_k back on 2026-10-21, and nothing in Anthropic’s general API versioning documentation suggests one exists. Staying on 2023-06-01 for the specific calls that need custom sampling is the documented path.



