fix(provider): enable thinking for google-vertex-anthropic models #10442
+1
−0
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.
Fixes reasoning/thinking not working for Claude models on GCP Vertex AI by correcting the npm package identifier and provider options key mapping.
Fixes #9894
What does this PR do?
Fixes reasoning/thinking not working for Claude models when using GCP Vertex AI.
I noticed that even when setting reasoning to "high" or "max", the responses were instant and showed no thinking content. After digging into the code, I found two issues:
Issue 1: The models.dev API returns
npm: "@ai-sdk/google-vertex"for the google-vertex-anthropic provider, but the variant generation logic expects the subpath import"@ai-sdk/google-vertex/anthropic". Without the correct npm identifier, no thinking variants were being generated.Issue 2: Even after fixing the npm package, the
sdkKey()function didn't have a mapping for"@ai-sdk/google-vertex/anthropic", so thinking options were being wrapped with the wrong provider key ("google-vertex-anthropic"instead of"anthropic"). The AI SDK didn't recognize this and just ignored the thinking config.Changes:
fromModelsDevModel()to transform the npm package to"@ai-sdk/google-vertex/anthropic"for google-vertex-anthropic modelssdkKey()to map"@ai-sdk/google-vertex/anthropic"→"anthropic"How did you verify your code works?
Tested locally by running
bun devand confirming that Claude Opus 4.5 on Vertex AI now properly shows thinking when using the "high" or "max" variants. It works properly now :)Also added unit tests that verify:
budgetTokens"anthropic"key