Add anthropic speed, fast mode for opus 4.6#4300
Merged
dsfaccini merged 38 commits intopydantic:mainfrom Apr 28, 2026
Merged
Conversation
fast mode for opus 4.6
bohdanhr
commented
Feb 12, 2026
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Collaborator
|
this is green now but the tests need to be made VCR |
dsfaccini
reviewed
Apr 17, 2026
Contributor
Author
|
@dsfaccini im consistently getting 429 throttled trying to make calls to anthropic with fast mode, would you be able to try? |
Collaborator
|
hey @bohdanhr I've actually been blocked for a couple days bc my personal org has no access to fast mode (waitlisted), I'm trying to use it through our gateway to see if that works |
Contributor
Author
|
@dsfaccini same here, we are not waitlisted either. |
…gnore - Revert task budget changes merged in from another feature; they belong in pydantic#5140 - Restrict fast-mode support to Claude Opus 4.6 only (per Anthropic docs) - Silently ignore `anthropic_speed` on unsupported models (no UserWarning), per DouweM's review and models/AGENTS.md convention - OMIT `speed` on unsupported models regardless of value (not just for 'fast') - Document prompt-cache invalidation when switching speeds, and that fast mode is not available on Bedrock/Vertex - Fix docs example to use claude-opus-4-6 - Remove stale untracked cassettes from failed real-API recording attempts
Fast mode is only available on the direct Anthropic API. Even when the model supports it (Opus 4.6), sending `speed` via Bedrock, Vertex, or Foundry clients would likely error at the provider gateway. Add `_FAST_MODE_UNSUPPORTED_CLIENTS` and check client type in `_effective_speed` and the fast-mode beta gate.
The `_FAST_MODE_UNSUPPORTED_CLIENTS` tuple already blocks fast mode on Foundry clients, but the user-facing docstring and docs admonition only listed Bedrock and Vertex. Update both so Foundry users know `anthropic_speed` is silently omitted on their client too.
dsfaccini
reviewed
Apr 23, 2026
Comment on lines
+1978
to
+1980
| from unittest.mock import AsyncMock, MagicMock | ||
|
|
||
| import anthropic |
Collaborator
There was a problem hiding this comment.
move these up top please
- _effective_speed emits UserWarning when 'fast' is set on an unsupported model or client (Bedrock/Vertex/Foundry); still omits `speed` from the request - Update anthropic_speed docstring to document the warning behavior - Move `import anthropic` and `AsyncMock, MagicMock` out of test_anthropic_speed_omitted_on_non_direct_clients to the top of tests/models/test_anthropic.py - Update tests to assert the warning (UserWarning with match) for the 'fast' + unsupported-model and non-direct-client cases
…rning)" This reverts commit cc9e2f7.
Per DouweM's review, the two-call split in `prepare_request` was deliberate: warn once against the user's input early, then silently scrub any sampling params re-introduced by the post-`super().prepare_request` merge of defaults. Earlier branch commits collapsed the two calls into one (e7aa77a) and then removed the now-unused `warn` param for coverage (a44ad41), which moved the warning point and could fire for params the user never set. This restores the original main-branch structure.
Alex-Resch
pushed a commit
to Alex-Resch/pydantic-ai
that referenced
this pull request
Apr 29, 2026
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Cursor <[email protected]> Co-authored-by: David Sanchez <[email protected]>
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.
Pre-Review Checklist
make formatandmake typecheck.Pre-Merge Checklist