fix(anthropic): allow both temperature and topP for non-Anthropic models#14052
Merged
gr2m merged 3 commits intorelease-v6.0from Apr 2, 2026
Merged
Conversation
The temperature/topP mutual exclusivity check was applied to all models using the @ai-sdk/anthropic provider, but providers like Minimax that use the Anthropic-compatible API may require both parameters. - Rename `isKnownModel` to `isKnownAnthropicModel` for clarity - Fall back to `true` for unknown models starting with `claude-` - Only enforce temperature/topP mutual exclusivity for known Anthropic models Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…heck Instead of baking the `claude-` prefix fallback into `getModelCapabilities`, introduce a derived `isAnthropicModel` variable that combines `isKnownAnthropicModel` with the `claude-` prefix check. Use this for the temperature/topP mutual exclusivity guard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lgrammel
approved these changes
Apr 2, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lgrammel
approved these changes
Apr 2, 2026
This was referenced Apr 2, 2026
gr2m
added a commit
that referenced
this pull request
Apr 2, 2026
…els (#14056) ## Background The `@ai-sdk/anthropic` provider enforces temperature/topP mutual exclusivity for all models, matching a constraint in the Anthropic API. However, providers like Minimax use the Anthropic-compatible API endpoint with non-Anthropic models (e.g. `MiniMax-M2.7`) that require both `temperature` and `top_p` to be set simultaneously. ## Summary - Introduce `isAnthropicModel` variable derived from `isKnownModel || modelId.startsWith('claude-')` - Only enforce temperature/topP mutual exclusivity for Anthropic models - Non-Anthropic models using the Anthropic-compatible API can now send both parameters ## Related Issues Port of #14052
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
The
@ai-sdk/anthropicprovider enforces temperature/topP mutual exclusivity for all models (#11458), matching a constraint in the Anthropic API. However, providers like Minimax use the Anthropic-compatible API endpoint with non-Anthropic models (e.g.MiniMax-M2.7) that require bothtemperatureandtop_pto be set simultaneously. The SDK currently dropstopPwhenever both are provided, with no way to override this behavior.Summary
isKnownModeltoisKnownAnthropicModelfor claritygetModelCapabilitiesto returntruefor unknown models whose ID starts withclaude-(forward-compatible with future Anthropic models)isKnownAnthropicModelas a guard for the temperature/topP mutual exclusivity check — non-Anthropic models using the Anthropic-compatible API can now send both parametersManual Verification
Created a test using a non-Anthropic model ID (
MiniMax-M2.7) that verifies bothtemperatureandtop_pare sent in the request body without warnings.Checklist
pnpm changesetin the project root)