Claude Code and Vertex AI integration not working

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 7 comments · opened Mar 3, 2025 · closed Mar 4, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

I've enabled the APIs in Google Vertex AI studio and I'm able to make the following request:

curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json; charset=utf-8" -d @request.json "https://us-east5-aiplatform.googleapis.com/v1/projects/<my-project-id>/locations/us-east5/publishers/anthropic/models/claude-3-7-sonnet@20250219:streamRawPredict"

and it gives back the appropriate response as per the input in request.json

I was trying to configure the Claude Code using 3rd party APIs

I have set the following env variables:

CLAUDE_CODE_USE_VERTEX=1
CLOUD_ML_REGION=us-east5
ANTHROPIC_VERTEX_PROJECT_ID=<my-project-id>

However, in Claude Code, I keep getting:Credit balance too low · Add funds: https://console.anthropic.com/settings/billing

What can I do to configure Claude Code to use the Vertex API?

Note: I'm on @anthropic-ai/claude-code@0.2.29

View original on GitHub ↗

7 Comments

alireza-farokhi · 1 year ago

i am trying the same thing. added the config valued in the project's .env file but claude keeps using it's own API. tried with both Vertex and Bedrock configs:
CLAUDE_CODE_USE_VERTEX=1 // commented
CLOUD_ML_REGION=us-east5 // commented
ANTHROPIC_VERTEX_PROJECT_ID=id // commented

CLAUDE_CODE_USE_BEDROCK=1
AWS_ACCESS_KEY_ID=myAccessKey
AWS_SECRET_ACCESS_KEY=theSecret
AWS_REGION=us-west-2

DISABLE_PROMPT_CACHING=1

i can see in Anthropic billing console my credit decreasing after each request

bcherny collaborator · 1 year ago

Can you double check that you're not setting ANTHROPIC_MODEL locally? That will override things for 3P.

varundhall · 1 year ago

@bcherny I don't have ANTHROPIC_MODEL set locally.

bcherny collaborator · 1 year ago

Are you sure you're setting the env vars correctly? What happens if you directly do:

CLAUDE_CODE_USE_VERTEX=1 CLOUD_ML_REGION=us-east5 ANTHROPIC_VERTEX_PROJECT_ID=id claude
varundhall · 1 year ago

@bcherny I've set the env variables properly, you can see the screenshot below

<img width="801" alt="Image" src="https://github.com/user-attachments/assets/9cbc3803-59cc-48fe-91c2-7237cf447f05" />

However, CLAUDE_CODE_USE_VERTEX=1 CLOUD_ML_REGION=us-east5 ANTHROPIC_VERTEX_PROJECT_ID=id Claude works for me.

I'm using zsh /bin/zsh. Is there any chance Claude Code is trying to use bash /bin/bash internally?

varundhall · 1 year ago

I've set the env variables for both bash and zsh, and now it works for me.

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.