Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
jfbloom22 wants to merge 4 commits into open-webui:main
base: main
Choose a base branch
Loading
from jfbloom22:main
Open

Conversation

Copy link
Contributor

@jfbloom22 jfbloom22 commented Oct 7, 2025
edited
Loading

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

  • Extended Thinking Support for Claude 4.5
  • Cache Control
  • Beta Features Support
  • Enhanced Model Handling
  • 6 New Valves

NIK-NUB reacted with thumbs up emoji
Copy link

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.
@jfbloom22 jfbloom22 changed the title (削除) support claude 4.5 (削除ここまで) (追記) support claude 4.* models (追記ここまで) Oct 9, 2025
Copy link
Contributor Author

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /