Skip to content

Conversation

@MichaelYochpaz
Copy link
Contributor

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:

  • Added special handling in fromModelsDevModel() to transform the npm package to "@ai-sdk/google-vertex/anthropic" for google-vertex-anthropic models
  • Updated sdkKey() to map "@ai-sdk/google-vertex/anthropic""anthropic"
  • Added tests that would have caught these issues (the new unit test specifically verifies the npm package transformation from models.dev data)

How did you verify your code works?

Tested locally by running bun dev and 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:

  • The npm package transformation happens correctly
  • Thinking variants are generated with proper budgetTokens
  • Provider options are wrapped with the correct "anthropic" key

Fixes reasoning/thinking not working for Claude models on GCP Vertex AI by correcting the npm package identifier and provider options key mapping.

The issue had two root causes:
1. models.dev API returns npm: '@ai-sdk/google-vertex' for google-vertex-anthropic provider, but variant generation expects '@ai-sdk/google-vertex/anthropic' (subpath import)
2. sdkKey() function didn't map '@ai-sdk/google-vertex/anthropic' to 'anthropic' key, causing thinking options to be wrapped with wrong provider key

Changes:
- Transform npm package to '@ai-sdk/google-vertex/anthropic' for google-vertex-anthropic provider in fromModelsDevModel()
- Add '@ai-sdk/google-vertex/anthropic' case to sdkKey() to return 'anthropic' key
- Add comprehensive tests for npm transformation, variant generation, and providerOptions key mapping
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@rekram1-node rekram1-node merged commit 0bc4a43 into anomalyco:dev Jan 25, 2026
5 of 6 checks passed
@MichaelYochpaz MichaelYochpaz deleted the fix/google-vertex-anthropic-thinking branch January 25, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reasoning Doesn't Work for Claude Models through Vertex Provider

2 participants