Skip to content
Claudexia TeamERRORS

Claude API 400 error: temperature, top_p, top_k (2026-10-21)

API version 2026-10-21 returns 400 for any request that sends temperature, top_p or top_k, even at the default value. What changed and how to fix it.

Getting a 400 after moving to API version 2026-10-21? Check first whether the request still carries temperature, top_p or top_k. Anthropic released this version on 21 October 2026. A request with any of the three parameters returns 400, and the default value does not save it. A request without them is not rejected for that reason. The fix is to delete the fields. Below: what else the version changed, how to find the parameters in a large codebase, and how to stay on the old version if you cannot do without them.

What changed in version 2026-10-21

Anthropic's migration guide for 2026-10-21 lists three Messages API changes that produce a 400. They apply to Messages requests, to token counting and to every request inside a Message Batch created with this version.

What the request containsWhat happens in 2026-10-21What to do
temperature, top_p or top_k in a Messages or Message Batches request400, even at the default valueRemove the three parameters
A document block directly in an assistant message400. A document nested inside another block, such as a web fetch result that Claude returned, is still acceptedSend documents in user messages
A text block in a user message with a non-empty citations array, including inside search_result400Remove citations from those blocks

Citations come with a carve-out. Citations on text blocks in assistant messages, meaning Claude's earlier replies that you send back, are still accepted. So is the "citations": {"enabled": true} setting on documents and search results.

Beyond the Messages API, the version renames fields in the Admin API and the Claude Enterprise Analytics API. API keys, for example, return scope instead of workspace_id. If your code reads those responses, check the Admin API section of the guide.

The new major SDK and CLI versions also change how the key travels. In Python, the Anthropic and AsyncAnthropic clients (the api_key argument and the ANTHROPIC_API_KEY variable) and AnthropicAWS (api_key and ANTHROPIC_AWS_API_KEY) send it as Authorization: Bearer instead of X-Api-Key, and so does the ant CLI. There are exceptions: AnthropicFoundry still sends its key as x-api-key, and AnthropicBedrockMantle already sent a bearer token. For the other languages the guide lists the same cases, with the same exception for the Foundry clients. The API accepts either header, so what breaks is not the request but a proxy or middleware that reads only X-Api-Key.

One more change affects code rather than requests: the Text Completions API is gone from the TypeScript, Go, Java and Ruby SDKs and from the CLI. Python dropped it earlier, in v1.0 on 20 August 2026. Use the Messages API instead.

What the error looks like

The documentation says only that the request returns 400. Neither the migration guide nor the errors page quotes a message for this case, so we do not print an exact string and do not invent one. We have not run requests with this version through our gateway either.

Claude API errors share one shape. By the errors page's status table, a 400 maps to the invalid_request_error type, and the body looks like this:

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "..."
  },
  "request_id": "req_..."
}

The Python SDK turns a 400 into anthropic.BadRequestError. In your logs, look for the 400 status and the request_id: you need it if you end up contacting Anthropic support. If the message names a different field rather than a sampling parameter, check the table above, because a document in an assistant message and citations in a user message produce the same status.

Who is affected

Four cases.

  • Direct calls through curl, requests or fetch that send anthropic-version: 2026-10-21.
  • Projects where the SDK was upgraded to Python 2.0.0, TypeScript 1.0.0, C# 13.0.0, Go 2.0.0, Java 3.0.0, PHP 1.0.0 or Ruby 2.0.0: these versions send 2026-10-21 by default.
  • Message Batches, where the parameters sit inside each request's params. In Python the type checker flags such a key, but according to the v1 migration guide the SDK still sends it, so the API is the one that returns the 400.
  • Code that always injects temperature: configs, wrappers, proxies. The docs say outright that the error comes even at the default value.

Not affected: requests without the three fields. They sample with the defaults, temperature 1.0 included, exactly like a 2023-06-01 request that leaves them out. Also not affected: anyone who stayed on an SDK of the previous major version, which sends 2023-06-01 by default. On Amazon Bedrock, 2026-10-21 is available only for Claude 4.7 and later; for models 4.6 and lower the guide says to keep the API version you use today.

How to fix it

The action is the same everywhere: remove temperature, top_p and top_k from the request body. In the latest major SDK and CLI versions the parameters are already gone from the types. For Python, the v1 migration guide (20 August 2026) says that passing temperature= raises a TypeError.

The examples use claude-sonnet-5. On Claudexia that model is available only in the Premium channel, so with a Cheap-only key pick a model from that channel's price list, claude-opus-5-5 for one.

Python

from anthropic import Anthropic

client = Anthropic(
    api_key="sk_cdx_...",
    base_url="https://api.claudexia.tech",
)

message = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude"}],
)

for block in message.content:
    if block.type == "text":
        print(block.text)

If a line like temperature=0.2 used to sit between max_tokens and messages, delete it.

TypeScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.CLAUDEXIA_API_KEY,
  baseURL: "https://api.claudexia.tech",
});

const message = await client.messages.create({
  model: "claude-sonnet-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello, Claude" }],
});

for (const block of message.content) {
  if (block.type === "text") {
    console.log(block.text);
  }
}

curl

curl https://api.claudexia.tech/v1/messages \
  -H "x-api-key: $CLAUDEXIA_API_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello, Claude"}]
  }'

This is the example from Anthropic's documentation with our address and model swapped in. We have not run it through the gateway with version 2026-10-21.

Gateway address and key

For the Anthropic SDK and Claude Code, the Claudexia gateway address is https://api.claudexia.tech, without /v1. Keys start with sk_cdx_. The gateway accepts both x-api-key and Authorization: Bearer, which covers the two ways Anthropic SDKs send a key: earlier versions and the Foundry client use x-api-key, the new standard clients use Authorization: Bearer. How the gateway behaves with version 2026-10-21 we have not tested.

Registration is on the sign-up page: a login and a password with confirmation, or sign-in through Google, GitHub or Telegram. There is no email field. The minimum top-up is $1, payable through SBP (rubles), a Russian bank card or crypto. The models page lists models and prices.

If you call the gateway not in the Anthropic format but through /v1/chat/completions with an OpenAI client, the guides on moving from OpenAI and on OpenAI-compatible migration cover changing the address and the key. How the gateway translates temperature from an OpenAI request into an Anthropic request we have not checked, so we say nothing about it.

If temperature controlled variety or consistency

Anthropic's document describes this case directly. Claude 4.7 and later models already accepted only the default values, so their behavior does not change. On models that accepted other values, Claude Sonnet 4.6 for one, a request that lowered temperature loses that effect. The document names no replacement: no other setting does the same job. You have two choices: stop sending the parameter, or keep that request on 2023-06-01.

Current models are included in this. According to the release notes, non-default values already returned 400 on Claude Opus 4.7 and Opus 4.8, on Claude Sonnet 5 (30 June 2026) and on Claude Haiku 5.5 (7 October 2026). Version 2026-10-21 adds one more rule: the default value now returns 400 too.

If you need several different answers to one task, you can send separate requests with different wording. That is our guess, not Anthropic's recommendation and not the result of any measurement.

Staying on 2023-06-01

Whoever sends the request sets the API version. Without an SDK it is a header:

curl https://api.claudexia.tech/v1/messages \
  -H "x-api-key: $CLAUDEXIA_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello, Claude"}]
  }'

With an SDK, the major version of the package sets the default: unless the header is overridden, requests carry the API version that was current when that major version was released. To avoid moving to 2026-10-21, do not upgrade to Python 2.0.0 or TypeScript 1.0.0.

pip install "anthropic<2"
npm install @anthropic-ai/sdk@0

Python has a catch. On the 1.x branch the temperature, top_p and top_k arguments are already gone from the methods, but for older models that still honor them the v1 migration guide suggests passing them through extra_body. That works only while you send 2023-06-01: on 2026-10-21, by the rule in the guide, such a request returns 400 as well.

You can also set the header inside the Python SDK through default_headers, but the documentation warns that overriding default headers can produce incorrect types and other undefined behavior. We have not tried it.

A caveat on the long term. Anthropic recommends using the latest API version, and the versions page (as of 17 November 2026) gives no retirement date for 2023-06-01. That is not a promise, so budget time for the move. For a similar exercise with retired models, see the model deprecation checklist.

Finding the parameters in a large codebase

Start with a search through the source. The -i flag catches topP and TOP_P, and -I skips binary files.

grep -rnEiI 'temperature|top_?p|top_?k' --exclude-dir={node_modules,.git,.venv} .

What to check in the results:

  • Claude calls. Leave other providers' parameters alone, OpenAI's included: they have their own rules.
  • Configs and environment variables such as LLM_TEMPERATURE that end up in the request.
  • Wrappers, proxies and middleware that add a parameter to every request.
  • Message Batches code and files: the parameter lives in each request's params.
  • Tests and fixtures that hold ready-made request bodies.

A temperature field inside a tool schema or in prompt text is not a request parameter. It is a word match.

While you are at it, find the places where the version is set by hand:

grep -rnEiI 'anthropic-version|anthropic_version' --exclude-dir={node_modules,.git,.venv} .

If the project has structured outputs or tool use calls, review them separately. The formats are covered in the articles on JSON and structured outputs and on function calling.

Checking which version you send

The installed SDK version tells you only the default. The header can be overridden for the whole client (default_headers) or per request (extra_headers), so after checking the version, search for such overrides with the command from the previous section. The package version in Python:

python -c "import anthropic; print(anthropic.__version__)"

In Node.js:

npm ls @anthropic-ai/sdk

The documentation names the first versions that use 2026-10-21: Python 2.0.0, TypeScript 1.0.0, C# 13.0.0, Go 2.0.0, Java 3.0.0, PHP 1.0.0, Ruby 2.0.0 and the ant CLI 2.0.0. A lower version means 2023-06-01 is sent by default.

For direct requests, read the anthropic-version header in the code and in the HTTP client settings. If a proxy sits between you and the API, the header that reaches the API decides the version, so check the proxy's logs too. The other 4xx and 5xx responses are covered in the guides to Claude API errors and to reading those errors.

FAQ

Why a 400 when I passed the default value?

In version 2026-10-21 the check looks at whether the parameter is present, not at its value. The document says so directly: the 400 comes even at the default value. That is why temperature=1 has to go too.

Is this the same error as "temperature and top_p cannot both be specified"?

No, that is an older case. By the release notes of 5 August 2025, Claude Opus 4.1 does not accept temperature and top_p together. In an issue in the BrowserOS tracker (issue 208, 26 November 2025), the same situation on Claude Sonnet 4.5 (the 29 September 2025 snapshot) is quoted as "temperature and top_p cannot both be specified for this model. Please use only one." We found no such wording in Anthropic's documentation. In 2026-10-21 each of the three parameters is rejected on its own.

What happens to requests that do not carry these parameters?

Nothing special: they sample with the defaults, and temperature is 1.0. The same held on 2023-06-01 without the parameters.

Can I change nothing and stay on the old version?

The document allows keeping a request on 2023-06-01, and the versions page names no retirement date for it. Anthropic does recommend the latest version, though. How much slack to leave is your call.

Does the Claudexia gateway pass these parameters through?

We do not know. We have not run requests with version 2026-10-21 through the gateway, so we cannot say that it passes the parameters, rejects them or strips them. The safest path does not depend on the gateway: remove the parameters from the request.