Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Claude Code and Vertex AI integration not working #284

Closed
varundhall opened this issue Mar 3, 2025 · 6 comments
Closed

Claude Code and Vertex AI integration not working #284

varundhall opened this issue Mar 3, 2025 · 6 comments
Assignees
Labels
api:vertex bug Something isn't working

Comments

@varundhall
Copy link

varundhall commented Mar 3, 2025

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/[email protected]

@alireza-farokhi
Copy link

alireza-farokhi commented Mar 3, 2025

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

@ashwin-ant ashwin-ant added bug Something isn't working api:vertex labels Mar 3, 2025
@bcherny
Copy link
Collaborator

bcherny commented Mar 3, 2025

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

@varundhall
Copy link
Author

@bcherny I don't have ANTHROPIC_MODEL set locally.

@bcherny
Copy link
Collaborator

bcherny commented Mar 3, 2025

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

@bcherny bcherny self-assigned this Mar 3, 2025
@varundhall
Copy link
Author

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

Image

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:vertex bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants