xtekky/gpt4free · error · RuntimeError

Project ID discovery failed - set ANTIGRAVITY_PROJECT_ID in

Error message

Project ID discovery failed - set ANTIGRAVITY_PROJECT_ID in environment.

What it means

Authentication is valid, but the project-discovery API call returned no project: _fetch_project_id came back empty/None. The account's token works, yet no eligible Google Cloud project for Antigravity could be found via the API. The message tells you the escape hatch: set ANTIGRAVITY_PROJECT_ID.

Source

Thrown at g4f/Provider/needs_auth/Antigravity.py:1025

            self._project_id = auth_project_id
            return auth_project_id

        # Fall back to API discovery
        try:
            access_token = self.auth_manager.get_access_token()
            if not access_token:
                raise RuntimeError(
                    "No valid access token available for project discovery"
                )

            async with aiohttp.ClientSession() as session:
                project = await self.auth_manager._fetch_project_id(
                    session=session, access_token=access_token
                )
            if project:
                self._project_id = project
                return project
            raise RuntimeError(
                "Project ID discovery failed - set ANTIGRAVITY_PROJECT_ID in environment."
            )
        except MissingAuthError:
            raise
        except Exception as e:
            debug.error(f"Failed to discover project ID: {e}")
            raise RuntimeError(
                "Could not discover project ID. Ensure authentication or set ANTIGRAVITY_PROJECT_ID."
            )

    @staticmethod
    def _messages_to_gemini_format(
        messages: list, media: MediaListType
    ) -> List[Dict[str, Any]]:
        format_messages = []
        for msg in messages:
            # Convert a ChatMessage dict to GeminiFormattedMessage dict
            role = "model" if msg["role"] == "assistant" else "user"

View on GitHub (pinned to 973504e177)

Solutions

  1. Set ANTIGRAVITY_PROJECT_ID=<your-gcp-project-id> in the environment — deterministic fix.
  2. Complete the onboarding/login flow fully so the Antigravity service registers a cloudaicompanion project for the account.
  3. Verify in Google Cloud Console that the intended project exists and has the Code Assist API enabled.

Example fix

# before
export ANTIGRAVITY_PROJECT_ID=

# after
export ANTIGRAVITY_PROJECT_ID=my-gcp-project-id
Defensive patterns

Strategy: fallback

Validate before calling

project = (Antigravity.auth_manager.get_project_id()
           if Antigravity.auth_manager else None)
if not project:
    project = os.environ.get("ANTIGRAVITY_PROJECT_ID")
if not project:
    raise RuntimeError("no project: run login or export ANTIGRAVITY_PROJECT_ID")

Try / catch

try:
    await antigravity.create_async_generator(...)
except RuntimeError as e:
    if "Project ID discovery failed" in str(e):
        os.environ["ANTIGRAVITY_PROJECT_ID"] = known_project_id  # fallback
        raise  # or retry with pinned project

Prevention

When it happens

Trigger: get_access_token() succeeds, but the Cloud Resource Manager / loadCodeAssist project lookup returns no usable project — e.g. the account belongs to no projects, all projects lack the required API, or onboarding was never completed so the service reports no cloudaicompanion project.

Common situations: New Google account with no GCP project created; project exists but Cloud AI Companion API disabled; onboarding step (error 106) was skipped or failed, so no project was associated.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/61e01290370b0c8a. Report an issue: GitHub.