mem0ai/mem0 · critical · ValueError

Google application credentials JSON is not provided. Please

Error message

Google application credentials JSON is not provided. Please provide a valid JSON path or set the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable.

What it means

Raised by VertexAIEmbedding.__init__ when Google credentials cannot be established: the GCPAuthenticator setup raised, no vertex_credentials_json path exists in config, and the GOOGLE_APPLICATION_CREDENTIALS env var is unset. It is the terminal fallback after both programmatic and environment-based credential discovery failed.

Source

Thrown at mem0/embeddings/vertexai.py:38

            "update": self.config.memory_update_embedding_type or "RETRIEVAL_DOCUMENT",
            "search": self.config.memory_search_embedding_type or "RETRIEVAL_QUERY",
        }

        # Set up authentication using centralized GCP authenticator
        # This supports multiple authentication methods while preserving environment variable support
        try:
            GCPAuthenticator.setup_vertex_ai(
                service_account_json=getattr(self.config, 'google_service_account_json', None),
                credentials_path=self.config.vertex_credentials_json,
                project_id=getattr(self.config, 'google_project_id', None)
            )
        except Exception:
            # Fall back to original behavior for backward compatibility
            credentials_path = self.config.vertex_credentials_json
            if credentials_path:
                os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = credentials_path
            elif not os.getenv("GOOGLE_APPLICATION_CREDENTIALS"):
                raise ValueError(
                    "Google application credentials JSON is not provided. Please provide a valid JSON path or set the 'GOOGLE_APPLICATION_CREDENTIALS' environment variable."
                )

        self.model = TextEmbeddingModel.from_pretrained(self.config.model)

    def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None):
        """
        Get the embedding for the given text using Vertex AI.

        Args:
            text (str): The text to embed.
            memory_action (optional): The type of embedding to use. Must be one of "add", "search", or "update". Defaults to None.
        Returns:
            list: The embedding vector.
        """
        embedding_type = "SEMANTIC_SIMILARITY"
        if memory_action is not None:
            if memory_action not in self.embedding_types:

View on GitHub (pinned to 001c235229)

Solutions

  1. Set vertex_credentials_json in the embedder config to the path of a service-account JSON file with Vertex AI User permission
  2. Or export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json before starting the process
  3. Or pass google_service_account_json (dict) plus google_project_id in the config so GCPAuthenticator resolves them programmatically
  4. Verify the JSON file exists and parses: python -c "import json;json.load(open('key.json'))"; ensure the Vertex AI API is enabled in the project

Example fix

// before
Memory.from_config({"embedder": {"provider": "vertexai"}})  # ValueError: credentials not provided

# after
Memory.from_config({"embedder": {"provider": "vertexai", "config": {
    "model": "text-embedding-004",
    "vertex_credentials_json": "/secrets/gcp-sa.json"
}}})
Defensive patterns

Strategy: validation

Validate before calling

import json, os

def gcp_ready(cfg) -> bool:
    sa = cfg.get("google_service_account_json")
    path = cfg.get("vertex_credentials_json")
    if sa and cfg.get("google_project_id"):
        return True
    if path and os.path.isfile(path):
        json.load(open(path))  # raises early on malformed JSON
        return True
    return bool(os.getenv("GOOGLE_APPLICATION_CREDENTIALS"))

assert gcp_ready(embedder_config), "no usable GCP credentials found"

Try / catch

try:
    embedder = VertexAIEmbedding(config)
except ValueError as e:
    if "credentials" in str(e).lower():
        raise SystemExit("Set vertex_credentials_json or GOOGLE_APPLICATION_CREDENTIALS") from e
    raise

Prevention

When it happens

Trigger: Initializing VertexAIEmbedding with no google_service_account_json, no vertex_credentials_json, and no GOOGLE_APPLICATION_CREDENTIALS env var; or when the authenticator path raised (malformed service-account JSON) and the fallback also found nothing

Common situations: Running mem0 in a container/CI without mounting the GCP key; assuming gcloud application-default credentials are enough (this code path wants a service-account JSON specifically); a typo in the credentials file path in the embedder config.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/7987917b38977ee9. Report an issue: GitHub.