mem0ai/mem0 · error · Error
Vertex AI could not determine a Google Cloud project ID. Set
Error message
Vertex AI could not determine a Google Cloud project ID. Set googleProjectId in config, one of the GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars, or configure Application Default Credentials: ${err.message} What it means
VertexAIEmbedder resolves the GCP project in three steps: explicit config.googleProjectId, the GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars, then Application Default Credentials via client.getProjectId(). This error means all of those failed, and the appended err.message explains why ADC resolution failed (e.g. no credentials, no quota project).
Source
Thrown at mem0-ts/src/oss/src/embeddings/vertexai.ts:121
});
}
await this.initPromise;
}
private async createClient(): Promise<void> {
const aiplatform: AIPlatform = await loadPeer(
"@google-cloud/aiplatform",
"Vertex AI embedding provider",
() => import("@google-cloud/aiplatform"),
);
const client = new aiplatform.PredictionServiceClient(this.clientOptions);
if (!this.projectId) {
try {
this.projectId = await client.getProjectId();
} catch (err) {
throw new Error(
"Vertex AI could not determine a Google Cloud project ID. Set googleProjectId in config, " +
"one of the GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env vars, or configure " +
"Application Default Credentials: " +
(err as Error).message,
);
}
}
this.client = client;
this.helpers = aiplatform.helpers;
}
private endpoint(): string {
return `projects/${this.projectId}/locations/${this.location}/publishers/google/models/${this.model}`;
}
private formatInstance(text: string, taskType: string) {
// task_type must live on the instance (snake_case), not in `parameters`.View on GitHub (pinned to 001c235229)
Solutions
- Pass googleProjectId explicitly in the embedder config: new VertexAIEmbedder({ googleProjectId: 'my-project', ... })
- Set one of GCP_PROJECT_ID, GOOGLE_CLOUD_PROJECT, or GCLOUD_PROJECT in the environment
- For local dev, run: gcloud auth application-default login
- For service accounts, set GOOGLE_APPLICATION_CREDENTIALS to the key file path and ensure the SA belongs to a project
- Read the trailing (err as Error).message: it names the exact ADC failure
Example fix
// before
const embedder = new VertexAIEmbedder({}); // relies on ADC which is absent
// after
const embedder = new VertexAIEmbedder({
googleProjectId: process.env.GCP_PROJECT_ID!,
googleServiceAccountJson: process.env.GCP_SA_JSON,
}); Defensive patterns
Strategy: validation
Validate before calling
const projectId = cfg.googleProjectId
?? process.env.GCP_PROJECT_ID
?? process.env.GOOGLE_CLOUD_PROJECT
?? process.env.GCLOUD_PROJECT;
if (!projectId && !process.env.GOOGLE_APPLICATION_CREDENTIALS) {
throw new Error("No GCP project: set googleProjectId, a GCP_PROJECT env var, or run gcloud auth application-default login");
} Type guard
function isProjectIdError(err: unknown): boolean {
return err instanceof Error && err.message.includes("could not determine a Google Cloud project ID");
} Try / catch
try {
await embedder.embed(text);
} catch (err) {
if (err instanceof Error && err.message.includes("could not determine a Google Cloud project ID")) {
throw new Error("Vertex config incomplete: pass googleProjectId explicitly");
}
throw err;
} Prevention
- Always pass googleProjectId explicitly in non-GCP environments
- Verify ADC once at startup: a quick client.getProjectId() health check
- Document required env vars (GCP_PROJECT_ID / GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT) in deployment manifests
When it happens
Trigger: Running outside GCP with no gcloud auth application-default login; GOOGLE_APPLICATION_CREDENTIALS pointing to a missing file; a service account whose metadata is reachable but has no resolvable project; none of the three env vars set and googleProjectId omitted from config.
Common situations: Local development after cloning a project that worked in GCE/Cloud Run; CI runner without ADC setup; the ADC file was revoked or deleted; workload identity not available in the target namespace.
Related errors
- Failed to parse googleServiceAccountJson: ${err.message}
- Google application credentials JSON is not provided. Please
- No valid GCP credentials found. Please provide one of: 1. se
- Project ID could not be determined. Please provide project_i
- projectId must be set to access webhooks
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/1258ae89a7a173eb.
Report an issue: GitHub.