Skip to content

fix(anthropic): anthropic with vertex works with service account json keys#157

Open
Cali0707 wants to merge 1 commit intocharmbracelet:mainfrom
Cali0707:fix-anthropic-vertex-json-key
Open

fix(anthropic): anthropic with vertex works with service account json keys#157
Cali0707 wants to merge 1 commit intocharmbracelet:mainfrom
Cali0707:fix-anthropic-vertex-json-key

Conversation

@Cali0707
Copy link

@Cali0707 Cali0707 commented Mar 4, 2026

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features). Not needed, this is a bug fix

The bug

Currently, when using this package with an anthropic model from vertex, it fails when trying to use service account json keys for auth. This is a common auth setup for e.g. CI/CD pipelines, or where orgs restrict user based ADC/API key creation.

In particular, this is the error that I was seeing (redacted project/region details):

"error":"Post \"https://<region>-aiplatform.googleapis.com/v1/projects/<projectID>/locations/<region>/publishers/anthropic/models/claude-opus-4-6:streamRawPredict\": oauth2: cannot fetch token: 400 Bad Request\nResponse: {\"error\":\"invalid_scope\",\"error_description\":\"Invalid OAuth scope or ID token audience provided.\"}"

Proposed fix

This is not an issue when using the google provider with vertex directly, as that gets the credentials through the google genai package, which sets the scope itself: https://github.com/googleapis/go-genai/blob/37134ea8c0c17d262c26ed46e31ada75406dff02/client.go#L366

All I changed is also setting this scope when using the vertex option in the anthropic provider

… keys

Signed-off-by: Calum Murray <cmurray@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants