Send one of the two. Anthropic documents the rule for Claude Haiku 4.5, developers hit the same 400 on Claude Opus 4.6 and Sonnet 4.6, and on Claude Opus 4.7 and later it tightens to neither. Often the culprit is a client or framework filling in the parameter you never set.
The error
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "`temperature` and `top_p` cannot both be specified for this model. Please use only one."
},
"request_id": "req_..."
}Causes and fixes at a glance
| Cause | Fix |
|---|---|
| Your code, or a framework under it, sends both | Send only the one you mean and delete the other key. |
| The second one is a “neutral” default, such as top_p: 1 | Reported to fail all the same. Remove the key rather than normalizing it. |
| An older LangChain JS or n8n build | Upgrade: @langchain/anthropic 1.3.24 or later, n8n 1.114.1 or later. |
| LiteLLM passes both through | Add additional_drop_params: ["top_p"] to that model. |
| You moved to Claude Opus 4.7 or later, Sonnet 5 or Fable 5 | Stricter rule there: remove both — any non-default value of either is rejected. |
Which Claude models enforce it (as of September 2026)
Anthropic's Haiku 4.5 migration guide: use only temperature or top_p, not both — setting both returns a 400 on Claude Haiku 4.5, a breaking change for code coming from Claude 3.x (https://platform.claude.com/docs/en/models/haiku-4-5/migration-guide). Anthropic's API release notes flagged the same rule at the Claude Opus 4.1 launch on August 5, 2025, a model since retired (https://platform.claude.com/docs/en/release-notes/api). AWS states it for Claude Sonnet 4.5 and Claude Haiku 4.5 on Bedrock (https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-request-response.html). We found no Anthropic page that states the rule for the 4.6 models, but developers report this exact 400 from Claude Opus 4.6 (OpenHands issue #12846) and Claude Sonnet 4.6 (opencommit issue #566). Claude Opus 4.7 and later are covered below: there, one is already too many.
Send one — and delete the other key
Keep temperature unless you have a reason not to: Anthropic's API reference describes top_p as recommended for advanced use cases only (https://platform.claude.com/docs/en/api/messages). Remove the second key rather than setting it to a value you think is neutral — a developer reported that a top_p of 1.0 next to a temperature of 0.3 still failed on Claude Sonnet 4.5 (n8n issue #18304).
from openai import OpenAI
client = OpenAI(base_url="https://api.kunavo.com/v1", api_key="sk-kn-...")
def one_sampling_knob(params: dict) -> dict:
"""Where the rule applies, send temperature or top_p, not both. Keep temperature."""
if params.get("temperature") is not None:
params.pop("top_p", None)
return params
sampling = one_sampling_knob({"temperature": 0.3, "top_p": 0.9}) # {"temperature": 0.3}
resp = client.chat.completions.create(
model="claude-haiku-4-5",
max_tokens=512,
messages=[{"role": "user", "content": "Classify this support ticket: ..."}],
**sampling,
)
print(resp.choices[0].message.content)Fix it in the client that adds the second one
LangChain JS: ChatAnthropic 0.3.x sent a default temperature alongside the top_p you set (issue #9258, fixed on the 0.3 line by PR #9362 in November 2025), and PR #10420, released in @langchain/anthropic 1.3.24 on March 17, 2026, stops it adding any sampling key you leave unset (https://github.com/langchain-ai/langchainjs/pull/10420). n8n: the Anthropic Chat Model node passed LangChain's defaults (topP -1, temperature 0.7); fixed in n8n 1.114.1, released October 2, 2025 (https://github.com/n8n-io/n8n/pull/20286). LiteLLM: name the parameter to remove with additional_drop_params, per call or per model (https://docs.litellm.ai/docs/completion/drop_params) — except on its Anthropic pass-through route, where the report was closed on the grounds that pass-through requests are not modified (https://github.com/BerriAI/litellm/issues/15097). Amazon Bedrock: set temperature or topP in the Converse inferenceConfig, or temperature or top_p in the InvokeModel body — never both (https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InferenceConfiguration.html).
model_list:
- model_name: claude-haiku-4-5
litellm_params:
model: openai/claude-haiku-4-5 # Kunavo speaks the OpenAI chat shape
api_base: https://api.kunavo.com/v1
api_key: sk-kn-...
additional_drop_params: ["top_p"] # keep temperature, never send top_pOn Claude Opus 4.7 and later, send neither
Newer models go further. Setting temperature, top_p or top_k to any non-default value on Claude Opus 4.7 and later models returns a 400 (https://platform.claude.com/docs/en/models/opus-5-5/migration-guide); the same holds for Claude Sonnet 5 (https://platform.claude.com/docs/en/models/sonnet-5/migration-guide) and carries over to Claude Fable 5 (https://platform.claude.com/docs/en/models/fable-5/migration-guide) and Fable 5.1 (https://platform.claude.com/docs/en/models/fable-5-1/migration-guide). The message changes — developers see “`temperature` is deprecated for this model.” — and Anthropic's API reference now marks all three parameters deprecated: on models released after Claude Opus 4.6 it accepts only a temperature of 1.0 or a top_p of 0.99 and above, for backwards compatibility, and rejects top_k at any value (https://platform.claude.com/docs/en/api/messages). The Anthropic Python SDK removed them from its Messages methods in v1.0, released August 20, 2026 (https://platform.claude.com/docs/en/release-notes/api).
If you’re calling through Kunavo
On the six claude-* models where Anthropic removed sampling — claude-fable-5-1, claude-fable-5, claude-opus-5, claude-opus-4-8, claude-opus-4-7 and claude-sonnet-5 — Kunavo deletes temperature, top_p and top_k from the request before it leaves the gateway, on /v1/chat/completions and /v1/messages alike. You will not see this error from those six, but the values you sent have no effect: the request goes upstream as if you had left them out. On claude-opus-4-6, claude-sonnet-4-6 and claude-haiku-4-5 Kunavo strips nothing: the chat translator copies any numeric temperature, top_p or top_k into the Claude request unchanged, and /v1/messages forwards your body as sent, so send one of the two there. If the upstream rejects the pair, its 400 reaches you with the upstream's message text unchanged, is not retried on another channel, and is recorded at zero cost. Another request parameter that newer models reject is covered in the max_tokens vs max_completion_tokens guide.
FAQ
Should I use temperature or top_p with Claude?
Temperature, unless you have a specific reason. Anthropic's API reference recommends top_p for advanced use cases only, and on Claude Opus 4.7 and later neither can be set to a non-default value.
Does top_p = 1 count as not setting it?
Don't count on it. A developer reported the same 400 with top_p at 1.0 alongside a temperature on Claude Sonnet 4.5 (n8n issue #18304). Delete the key instead of setting it to a value that looks neutral.
Why does n8n or LangChain send top_p when I never set it?
Both passed defaults through. n8n's Anthropic Chat Model node sent LangChain's defaults (topP -1, temperature 0.7) until 1.114.1, and ChatAnthropic in LangChain JS 0.3.x sent a default temperature alongside the top_p you set. Upgrade: n8n 1.114.1 or later, @langchain/anthropic 1.3.24 or later.
What does “`temperature` is deprecated for this model” mean?
It is the stricter rule on Claude Opus 4.7 and later, Sonnet 5 and Fable 5 and 5.1: those models reject non-default sampling values outright. Remove the parameters. Through Kunavo, the ones we serve have them stripped, so the call goes through.
Does a rejected request cost anything on Kunavo?
No. A request the upstream rejects is recorded at zero cost.
Related guides
- “This model does not support assistant message prefill” — which Claude models dropped prefill, and what replaces it
- “Unsupported parameter: 'max_tokens' is not supported with this model” — use max_completion_tokens
- n8n AI API cost: one execution, many model calls, two bills
- Claude API — the complete guide to calling Claude on Kunavo
More error semantics live in the error reference; getting a key takes a minute via sign up and the authentication docs.