{"record":{"id":"fa4f2962b100b706","repo":"continuedev/continue","slug":"vertexai-in-express-mode-apikey-only-cannot-be-c","errorCode":null,"errorMessage":"VertexAI in express mode (apiKey only) cannot be configured with region, projectId, keyFile, or keyJson","messagePattern":"VertexAI in express mode \\(apiKey only\\) cannot be configured with region, projectId, keyFile, or keyJson","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/VertexAI.ts","lineNumber":80,"sourceCode":"      this.genAI = new GoogleGenAI({ apiKey });\n    } else if (env?.projectId && env?.region) {\n      this.genAI = new GoogleGenAI({\n        vertexai: true,\n        project: env.projectId,\n        location: env.region,\n      });\n    }\n  }\n\n  private setupAuthentication(): void {\n    const { apiKey, env } = this.config;\n    const { region, projectId, keyFile, keyJson } = env || {};\n\n    // Validate authentication configuration\n    if (apiKey) {\n      // Express mode validation\n      if (region || projectId || keyFile || keyJson) {\n        throw new Error(\n          \"VertexAI in express mode (apiKey only) cannot be configured with region, projectId, keyFile, or keyJson\",\n        );\n      }\n    } else {\n      // Standard mode validation\n      if (!region || !projectId) {\n        throw new Error(\n          \"region and projectId are required for VertexAI (when not using express/apiKey mode)\",\n        );\n      }\n      if (keyFile && keyJson) {\n        throw new Error(\n          \"VertexAI credentials can be configured with either keyFile or keyJson but not both\",\n        );\n      }\n    }\n\n    // Set up authentication client","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/VertexAI.ts#L62-L98","documentation":"VertexAI setupAuthentication runs in express mode when apiKey is set; it forbids mixing express mode with standard-mode credentials. If any of region, projectId, keyFile, or keyJson is also present, this error is thrown from the constructor.","triggerScenarios":"Constructing VertexAIApi with apiKey plus region/projectId/keyFile/keyJson in env/config (e.g. GOOGLE_VERTEX_REGION set alongside VERTEX_API_KEY).","commonSituations":"Shared .env files containing leftover service-account variables while switching to express API-key auth; CI environments injecting GOOGLE_CLOUD_PROJECT globally; combining examples from both auth modes.","solutions":["Remove region, projectId, keyFile, and keyJson from the Vertex config and keep only apiKey (express mode)","Or drop apiKey and provide region + projectId (plus keyFile or keyJson) for standard service-account mode","Audit env vars like GOOGLE_VERTEX_REGION, GOOGLE_CLOUD_PROJECT that leak into the adapter config"],"exampleFix":"// before\nnew VertexAIApi({ apiKey, env: { region: 'us-central1', projectId: 'my-proj' } })\n// after\nnew VertexAIApi({ apiKey })","handlingStrategy":"validation","validationCode":"const { apiKey, region, projectId, keyFile, keyJson } = cfg; if (apiKey && (region || projectId || keyFile || keyJson)) throw new Error('Remove standard-mode fields or the apiKey');","typeGuard":"const isCleanExpressConfig = (c: VertexConfig) => !!c.apiKey && !c.env?.region && !c.env?.projectId && !c.env?.keyFile && !c.env?.keyJson;","tryCatchPattern":"try { new VertexAIApi(cfg); } catch (e) { if (e.message.includes('express mode')) throw new ConfigError('Pick one VertexAI auth mode'); throw e; }","preventionTips":["Pick exactly one auth mode: apiKey OR service-account fields","Audit .env for leftover GOOGLE_* variables when switching modes"],"tags":["vertexai","config","authentication","conflicting-options"],"backgroundTag":"invalid-configuration","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}