Anthropic API · sdk · fg-0478

temperature or top_p returns 400, or a TypeError in the Python SDK, on Claude Opus 4.7 and later

If you see 400 invalid_request_error naming temperature, top_p, or top_k, the cause and the fix for Anthropic API are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
400 invalid_request_error naming temperature, top_p, or top_kTypeError from client.messages.create when temperature is passed (anthropic Python SDK 1.0 and later)temperature=0 kept for determinism breaks the request after a model upgrade
Cause
Any non-default temperature, top_p, or top_k is rejected on Opus 4.7 and later and on Haiku 5.5, and the Python SDK from 1.0 no longer defines these arguments at all. Haiku 5.5 accepts only the defaults, temperature 1 or top_p 0.99, and never both.
Fix
Delete temperature, top_p, and top_k from every request and steer behavior through the prompt. Note that temperature 0 never guaranteed identical outputs anyway.
Apply
params = {k: v for k, v in params.items() if k not in ("temperature", "top_p", "top_k")} msg = client.messages.create(**params)
Affected
Claude Opus 4.7, 4.8, 5, 5.5, Fable 5 and 5.1, Haiku 5.5; anthropic Python SDK 1.0 and later; as of 2026-10
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun