-
Notifications
You must be signed in to change notification settings - Fork 14
support claude 4.* models #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
christian-taillon
commented
Oct 7, 2025
Hello @jfbloom22! Thank you so much for your work on this. The community needs a better go to Anthropic integration that is supported/updated. If this is approved, I'll reach out to Justin to suggest this as a consideration for the update to our Pipe on the Open WebUI community site.
One problem I have with your implementation of Opus4.1 (for all the API token rich out there): Claude Opus 4.1 has the same constraint and returns 400: "temperature and top_p cannot both be specified for this model." Please gate Opus 4.x the same way as Sonnet 4.5 so only one sampler is sent.
Suggested change:
# Handle temperature/top_p settings ONE_SAMPLER_PREFIXES = ("claude-sonnet-4-5", "claude-opus-4") if api_model_name.startswith(ONE_SAMPLER_PREFIXES): if is_thinking_model: payload.pop("top_p", None) payload["temperature"] = 1.0 elif self.valves.CLAUDE_45_USE_TEMPERATURE: payload.pop("top_p", None) payload["temperature"] = body.get("temperature", 0.8) else: payload.pop("temperature", None) payload["top_p"] = body.get("top_p", 0.9) else: # Other Claude models support both payload["temperature"] = body.get("temperature", 0.8) payload["top_p"] = body.get("top_p", 0.9)
This will prevent the 400 on Opus 4.1 while keeping existing behavior for 4.5.
Thank you!
- Updated valve naming for temperature settings to be more generic for Claude 4.x models. - Added a new method to determine if a model is a Claude 4.x generation model with temperature/top_p constraints.
@christian-taillon Thanks for the feedback. I am trying to make this a bit more future proof and as best I can tell Anthropic intends to only support top_p or temperature for all 4.* models. I added a dedicated pattern match:
def _is_claude_4x_model(self, model_name: str) -> bool:
"""
Determine if a model is a Claude 4.x generation model that has temperature/top_p constraints.
Uses a more future-proof approach than simple prefix matching.
Args:
model_name: The model name to check
Returns:
True if this is a Claude 4.x model with constraints
"""
import re
# Pattern to match Claude 4.x models with various version suffixes
# Examples: claude-opus-4, claude-opus-4-1-20250805, claude-sonnet-4-5, claude-sonnet-4-5-20250929
# The pattern allows for optional sub-versions (like -1, -5) and dates
pattern = r"^claude-(opus|sonnet)-4(?:-\d+)?(?:-\d{8})?$"
return bool(re.match(pattern, model_name))
```
What do you think?
Uh oh!
There was an error while loading. Please reload this page.
Claude 4.5 (and Claude Opus 4.1) has a strict API constraint that prevents specifying both temperature and top_p parameters simultaneously.
updated your anthropic/main.py pipe with intelligent parameter handling
Smart Detection: The pipe detects if both parameters are provided by checking if they're different from their defaults
Priority Logic: If both are provided, it prioritizes temperature (most common use case)
Fallback: If only top_p is provided, it uses top_p instead