---
url: >-
  https://docs.byesu.com/en/errors/claude-api-400-temperature-top-p-not-supported.md
description: >-
  Fix Anthropic 400 Bad Request when passing temperature, top_p, or top_k on API
  version 2026-10-21 and newer SDKs: omit sampling params or pin 2023-06-01.
---

# Claude API 400: `temperature`, `top_p`, and `top_k` Not Supported (`2026-10-21`)

After upgrading to Anthropic API version **`2026-10-21`** (the default in Anthropic Python SDK `v2.0.0+` and TypeScript SDK `v1.0.0+`), sending `temperature`, `top_p`, or `top_k` in `/v1/messages` returns **HTTP 400 `invalid_request_error`** — even if you pass the default value like `temperature: 1.0`.

::: tip Quick answer

1. **Recommended fix**: Remove `temperature`, `top_p`, and `top_k` completely from your request payload (do not send `1.0` or `0.0`).
2. **Temporary rollback**: If legacy wrappers inject `temperature` automatically, pin the header `anthropic-version: 2023-06-01` until you can strip the parameter.
   :::

## Why It Happens

In API version `2026-10-21`, Anthropic removed the legacy sampling parameters (`temperature`, `top_p`, `top_k`) from the Messages request schema for current models using adaptive thinking. Because schema validation rejects unknown fields, passing any of them triggers a `400 Bad Request` (`Extra inputs are not permitted` or `invalid_request_error`).

```json
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "temperature: Extra inputs are not permitted"
  }
}
```

## Fix 1: Remove Sampling Parameters From Your Request

Before (fails on `2026-10-21` / Python SDK v2+):

```python
response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    temperature=0.2,   # triggers 400 on 2026-10-21
    top_p=0.9,         # triggers 400 on 2026-10-21
    messages=[{"role": "user", "content": "Summarize this diff."}],
)
```

After (works across `2026-10-21` and `2023-06-01`):

```python
response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Summarize this diff."}],
)
```

If you use an orchestration framework (LangChain, LlamaIndex, LiteLLM, or a custom chat UI) that injects `temperature` by default, disable or unset it in the model config so the key is omitted from the outgoing JSON body.

## Fix 2: Pin `anthropic-version: 2023-06-01` While Migrating

If you cannot modify a third-party client immediately, explicitly pin the older API version header in raw HTTP calls (or stay on the previous SDK major version until ready):

```bash
curl https://byesu.com/v1/messages \
  -H "Authorization: Bearer $BYESU_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-5-5","max_tokens":256,"messages":[{"role":"user","content":"Hello"}]}'
```

## Other Breaking 400 Changes in `2026-10-21`

If removing `temperature` / `top_p` / `top_k` still returns 400 after upgrading SDKs, check two companion changes introduced in `2026-10-21`:

* **`document` blocks inside `assistant` messages** are rejected — move `document` blocks to `user` turns.
* **Non-empty `citations` arrays on `user` text blocks** are rejected — strip `citations` from user-side content blocks.

Also check [Claude 400 thinking cannot be disabled](/en/errors/claude-api-400-thinking-disabled-not-supported) and [Claude 400 roles must alternate](/en/errors/claude-api-400-messages-role-alternation) if you see related schema errors.

## Verifying via a Gateway

When calling Claude through [byesu](https://byesu.com), send native `/v1/messages` requests to `https://byesu.com` without `temperature`/`top_p`/`top_k`, or verify live route health on the [status page](https://byesu.com/status).
