diff --git a/src/pygpt_net/provider/api/anthropic/chat.py b/src/pygpt_net/provider/api/anthropic/chat.py index 66e7cd549..8ed0f5e5d 100644 --- a/src/pygpt_net/provider/api/anthropic/chat.py +++ b/src/pygpt_net/provider/api/anthropic/chat.py @@ -102,10 +102,11 @@ def send(self, context: BridgeContext, extra: Optional[Dict[str, Any]] = None): # Add optional fields only if provided if system_prompt: params["system"] = system_prompt # SDK expects string or blocks, not None - if temperature is not None: - params["temperature"] = temperature # keep as-is; upstream config controls the type - if top_p is not None: - params["top_p"] = top_p + # Claude 4.x: top_p is rejected when temperature is also present. + # Opus 4.x and claude-3-7-sonnet have deprecated temperature entirely (extended thinking). + _no_temp = ("claude-opus-4-", "claude-3-7-sonnet") + if temperature is not None and not any(model.id.startswith(p) for p in _no_temp): + params["temperature"] = temperature if tools: # only include when non-empty list params["tools"] = tools # must be a valid list per API if mcp_servers: