continuedev/continue · error · Error
VertexAI in express mode (apiKey only) cannot be configured
Error message
VertexAI in express mode (apiKey only) cannot be configured with region, projectId, keyFile, or keyJson
What it means
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.
Source
Thrown at packages/openai-adapters/src/apis/VertexAI.ts:80
this.genAI = new GoogleGenAI({ apiKey });
} else if (env?.projectId && env?.region) {
this.genAI = new GoogleGenAI({
vertexai: true,
project: env.projectId,
location: env.region,
});
}
}
private setupAuthentication(): void {
const { apiKey, env } = this.config;
const { region, projectId, keyFile, keyJson } = env || {};
// Validate authentication configuration
if (apiKey) {
// Express mode validation
if (region || projectId || keyFile || keyJson) {
throw new Error(
"VertexAI in express mode (apiKey only) cannot be configured with region, projectId, keyFile, or keyJson",
);
}
} else {
// Standard mode validation
if (!region || !projectId) {
throw new Error(
"region and projectId are required for VertexAI (when not using express/apiKey mode)",
);
}
if (keyFile && keyJson) {
throw new Error(
"VertexAI credentials can be configured with either keyFile or keyJson but not both",
);
}
}
// Set up authentication clientView on GitHub (pinned to 5522c6f44c)
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
Example fix
// before
new VertexAIApi({ apiKey, env: { region: 'us-central1', projectId: 'my-proj' } })
// after
new VertexAIApi({ apiKey }) Defensive patterns
Strategy: validation
Validate before calling
const { apiKey, region, projectId, keyFile, keyJson } = cfg; if (apiKey && (region || projectId || keyFile || keyJson)) throw new Error('Remove standard-mode fields or the apiKey'); Type guard
const isCleanExpressConfig = (c: VertexConfig) => !!c.apiKey && !c.env?.region && !c.env?.projectId && !c.env?.keyFile && !c.env?.keyJson;
Try / catch
try { new VertexAIApi(cfg); } catch (e) { if (e.message.includes('express mode')) throw new ConfigError('Pick one VertexAI auth mode'); throw e; } Prevention
- Pick exactly one auth mode: apiKey OR service-account fields
- Audit .env for leftover GOOGLE_* variables when switching modes
When it happens
Trigger: Constructing VertexAIApi with apiKey plus region/projectId/keyFile/keyJson in env/config (e.g. GOOGLE_VERTEX_REGION set alongside VERTEX_API_KEY).
Common situations: 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.
Related errors
- region and projectId are required for VertexAI (when not usi
- URL is not defined in params
- Response body is null
- Profile ${profileId} not found
- No workspace directories found. Make sure you've opened a fo
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/fa4f2962b100b706.
Report an issue: GitHub.