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
7 Comments
i am trying the same thing. added the config valued in the project's
.envfile but claude keeps using it's own API. tried with both Vertex and Bedrock configs:CLAUDE_CODE_USE_VERTEX=1 // commentedCLOUD_ML_REGION=us-east5 // commentedANTHROPIC_VERTEX_PROJECT_ID=id // commentedCLAUDE_CODE_USE_BEDROCK=1AWS_ACCESS_KEY_ID=myAccessKeyAWS_SECRET_ACCESS_KEY=theSecretAWS_REGION=us-west-2DISABLE_PROMPT_CACHING=1i can see in Anthropic billing console my credit decreasing after each request
Can you double check that you're not setting
ANTHROPIC_MODELlocally? That will override things for 3P.@bcherny I don't have
ANTHROPIC_MODELset locally.Are you sure you're setting the env vars correctly? What happens if you directly do:
@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 Claudeworks for me.I'm using zsh
/bin/zsh. Is there any chance Claude Code is trying to use bash/bin/bashinternally?I've set the env variables for both bash and zsh, and now it works for me.
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.