BerriAI/litellm · error · ValueError

Could not resolve project_id

Error message

Could not resolve project_id

What it means

Raised at the end of load_auth: credentials resolved, but no project_id could be determined from the argument, the service-account JSON, or Application Default Credentials — Vertex requires a project for its URLs, so auth cannot complete.

Source

Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:193

            else:
                creds = self._credentials_from_service_account(
                    json_obj,
                    scopes=["https://www.googleapis.com/auth/cloud-platform"],
                )

            if project_id is None:
                project_id = getattr(creds, "project_id", None)
        else:
            creds, creds_project_id = self._credentials_from_default_auth(
                scopes=["https://www.googleapis.com/auth/cloud-platform"]
            )
            if project_id is None:
                project_id = creds_project_id

        self.refresh_auth(creds)

        if not project_id:
            raise ValueError("Could not resolve project_id")

        if not isinstance(project_id, str):
            raise TypeError(f"Expected project_id to be a str but got {type(project_id)}")

        return creds, project_id

    # Google Auth Helpers -- extracted for mocking purposes in tests
    def _credentials_from_identity_pool(self, json_obj, scopes):
        try:
            from google.auth import identity_pool
        except ImportError:
            raise ImportError(GOOGLE_IMPORT_ERROR_MESSAGE)

        creds = identity_pool.Credentials.from_info(json_obj)
        if scopes and hasattr(creds, "requires_scopes") and creds.requires_scopes:
            creds = creds.with_scopes(scopes)
        return creds

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set the project explicitly via vertex_project parameter or the VERTEXAI_PROJECT environment variable.
  2. Ensure the credentials in use contain a project_id (service account JSON includes it).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:193 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/746d6c1cbacb1cd2. Report an issue: GitHub.