diff --git a/studio/backend/core/inference/external_provider.py b/studio/backend/core/inference/external_provider.py index f18075a6a3..04f9b15c74 100644 --- a/studio/backend/core/inference/external_provider.py +++ b/studio/backend/core/inference/external_provider.py @@ -276,8 +276,13 @@ class ExternalProviderClient: # Anthropic rejects requests that set both temperature and top_p "stream": True, } - if top_k is not None and top_k > 0: - body["top_k"] = top_k + # top_k is deprecated on Claude 4.x (Opus / Sonnet / Haiku 4.x return + # 400 with `top_k is deprecated for this model`). It was always + # optional on the older 3.x line too, so we just stop forwarding it + # for every Anthropic call rather than maintaining a per-model gate. + # ``top_k`` is still accepted on the method signature for API + # symmetry with the other stream methods. + del top_k if system: body["system"] = system diff --git a/studio/frontend/src/features/chat/provider-capabilities.ts b/studio/frontend/src/features/chat/provider-capabilities.ts index fd96aa3d6b..b02ec4eaaa 100644 --- a/studio/frontend/src/features/chat/provider-capabilities.ts +++ b/studio/frontend/src/features/chat/provider-capabilities.ts @@ -75,11 +75,14 @@ const PROVIDER_CAPABILITIES: Record = { repetitionPenalty: false, presencePenalty: false, }, - // Anthropic's Messages API accepts top_k but not presence/frequency penalty. + // Anthropic's Messages API rejects presence/frequency penalty, and top_k + // is now deprecated across the Claude 4.x line (Opus / Sonnet / Haiku 4.x + // 400 with "top_k is deprecated for this model"). It was always optional + // on the older 3.x line, so we just drop it for every Anthropic call. anthropic: { temperature: true, topP: true, - topK: true, + topK: false, minP: false, repetitionPenalty: false, presencePenalty: false,