File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/api/src/endpoints/google Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ export function getGoogleConfig(
9898 const serviceKey =
9999 typeof serviceKeyRaw === 'string' ? JSON . parse ( serviceKeyRaw ) : ( serviceKeyRaw ?? { } ) ;
100100
101- const project_id = serviceKey ?. project_id ?? null ;
102101 const apiKey = creds [ AuthKeys . GOOGLE_API_KEY ] ?? null ;
102+ const project_id = ! apiKey ? ( serviceKey ?. project_id ?? null ) : null ;
103103
104104 const reverseProxyUrl = options . reverseProxyUrl ;
105105 const authHeader = options . authHeader ;
@@ -128,14 +128,18 @@ export function getGoogleConfig(
128128 }
129129
130130 // If we have a GCP project => Vertex AI
131- if ( project_id && provider === Providers . VERTEXAI ) {
131+ if ( provider === Providers . VERTEXAI ) {
132132 ( llmConfig as VertexAIClientOptions ) . authOptions = {
133133 credentials : { ...serviceKey } ,
134134 projectId : project_id ,
135135 } ;
136136 ( llmConfig as VertexAIClientOptions ) . location = process . env . GOOGLE_LOC || 'us-central1' ;
137137 } else if ( apiKey && provider === Providers . GOOGLE ) {
138138 llmConfig . apiKey = apiKey ;
139+ } else {
140+ throw new Error (
141+ `Invalid credentials provided. Please provide either a valid API key or service account credentials for Google Cloud.` ,
142+ ) ;
139143 }
140144
141145 const shouldEnableThinking =
You can’t perform that action at this time.
0 commit comments