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

Calum Murray created

Signed-off-by: Calum Murray <cmurray@redhat.com>

Change summary

providers/anthropic/anthropic.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Detailed changes

providers/anthropic/anthropic.go 🔗

@@ -30,6 +30,8 @@ const (
 	Name = "anthropic"
 	// DefaultURL is the default URL for the Anthropic API.
 	DefaultURL = "https://api.anthropic.com"
+	// VertexAuthScope is the auth scope required for vertex auth if using a Service Account JSON file (e.g. GOOGLE_APPLICATION_CREDENTIALS).
+	VertexAuthScope = "https://www.googleapis.com/auth/cloud-platform"
 )
 
 type options struct {
@@ -171,7 +173,7 @@ func (a *provider) LanguageModel(ctx context.Context, modelID string) (fantasy.L
 			credentials = &google.Credentials{TokenSource: &googleDummyTokenSource{}}
 		} else {
 			var err error
-			credentials, err = google.FindDefaultCredentials(ctx)
+			credentials, err = google.FindDefaultCredentials(ctx, VertexAuthScope)
 			if err != nil {
 				return nil, err
 			}