https://www.boundaryml.com logo
🟡 Difficulty with Authentication for Claude model...
# questions
s
Hey folks, trying to use Claude models hosted on Google's Vertex AI with BAML. Tried this but seems like there's an authentication error thrown - We used vertex-ai with Gemini 3 (same API key) without any issues:
Copy code
client<llm> 

VertexAIClaudeOpus45 {
    provider vertex-ai
    options {
        model claude-opus-4-5
        location global
        project_id coldreach
        query_params {
            key env.VERTEX_AI_API_KEY
        }
    }
}
Errors thrown:
Copy code
InvalidAuthentication (401) Request failed with status code: 401 Unauthorized, 
[{
  "error": {
    "code": 401,
    "message": "API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal. See https://cloud.google.com/docs/authentication",
    "status": "UNAUTHENTICATED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "CREDENTIALS_MISSING",
        "domain": "googleapis.com",
        "metadata": {
          "service": "aiplatform.googleapis.com",
          "method": "google.cloud.aiplatform.v1.PredictionService.StreamRawPredict"
        }
      }
    ]
  }
}
]

Request options: {"anthropic_version":"2023-06-01","max_tokens":4096}
Are we expected to use some different authentication method? If so, what's the proper BAML syntax?
v
huh, thats odd we have some tests that use these models, let me look up the code. I think @Ben Epstein also uses those models. can you share your client definition @Shen
s
Hey @Vaibhav (BAML 🐑) ! What I shared above is the client definition - Were you looking for something else?
client VertexAIClaudeOpus45 { provider vertex-ai options { model claude-opus-4-5 location global project_id coldreach query_params { key env.VERTEX_AI_API_KEY } } }
v
oh whoops! Sorry was early and missed the first part!
s
oh great. It looks like they need a different authentication method for the Claude models? Not sure what's the right syntax on BAML for that
v
Copy code
client<llm> VertexClaude {
  provider vertex-ai
  options {
    model "claude-sonnet-4-5@20250929"
    location us-east5
    anthropic_version "vertex-2023-10-16"
    credentials env.INTEG_TESTS_GOOGLE_APPLICATION_CREDENTIALS_CONTENT
  }
}
s
Gotcha
v
i think you may need anthropic version
and i think your model may be wrong
same auth should work tho
s
oh
Just chatted with Claude and it thinks they don't work with API in this case, and we need to pass in a JSON key like the way you did
v
ah got it 🥲
vertex is such an interesting case for how they built software haha
s
Yeah.. Trying to figure out how to get that mysterious JSON key
v
Copy code
You can obtain Google Cloud credentials in JSON format by either downloading a Service Account key from the Google Cloud console or by using the gcloud CLI for local Application Default Credentials (ADC). 
Method 1: Download a Service Account Key (for server/non-interactive use) 
A service account is recommended for applications running in a production or non-interactive environment (e.g., servers, VMs). 
Go to the Service Accounts page in the Google Cloud console.
Select your project and then click on the service account you need credentials for (or create a new one if necessary).
Navigate to the "Keys" tab and click Add Key > Create new key.
Select "JSON" as the key type and click Create.
The JSON file will be generated and downloaded to your machine. This file is your only copy and should be stored securely. 
To use this file in your application, set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the file's full path:
a
let me know if something isn't super clear
i
Wait till you try to paste this into Vercel and it yells at you for white space errors. So stupid by GCP
3 Views