Skip to content

fix(anthropic): allow both temperature and topP for non-Anthropic models#14052

Merged
gr2m merged 3 commits intorelease-v6.0from
fix/anthropic-temperature-top-p-non-anthropic-models
Apr 2, 2026
Merged

fix(anthropic): allow both temperature and topP for non-Anthropic models#14052
gr2m merged 3 commits intorelease-v6.0from
fix/anthropic-temperature-top-p-non-anthropic-models

Conversation

@gr2m
Copy link
Copy Markdown
Collaborator

@gr2m gr2m commented Apr 2, 2026

Background

The @ai-sdk/anthropic provider 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 both temperature and top_p to be set simultaneously. The SDK currently drops topP whenever both are provided, with no way to override this behavior.

Summary

  • Renamed isKnownModel to isKnownAnthropicModel for clarity
  • Updated the fallback in getModelCapabilities to return true for unknown models whose ID starts with claude- (forward-compatible with future Anthropic models)
  • Added isKnownAnthropicModel as a guard for the temperature/topP mutual exclusivity check — non-Anthropic models using the Anthropic-compatible API can now send both parameters

Manual Verification

Created a test using a non-Anthropic model ID (MiniMax-M2.7) that verifies both temperature and top_p are sent in the request body without warnings.

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

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>
@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/anthropic Issues related to the @ai-sdk/anthropic provider labels Apr 2, 2026
…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>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
@gr2m gr2m merged commit 94aed06 into release-v6.0 Apr 2, 2026
17 checks passed
@gr2m gr2m deleted the fix/anthropic-temperature-top-p-non-anthropic-models branch April 2, 2026 16:06
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

vercel-ai-sdk bot commented Apr 2, 2026

🚀 Published in:

Package Version
@ai-sdk/amazon-bedrock 4.0.88
@ai-sdk/anthropic 3.0.65
@ai-sdk/google-vertex 4.0.99

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

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/anthropic Issues related to the @ai-sdk/anthropic provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants