Fosowl/agenticSeek · error · Exception

GOOGLE API error: {str(e)}

Error message

GOOGLE API error: {str(e)}

What it means

This is the generic wrapper error google_fn() raises for ANY exception from the Google API call block, with the original message embedded. It uses 'raise ... from e' so the underlying cause (auth errors, HTTP 4xx/5xx, JSON errors, or even error 26) is preserved in the chain. It means the Gemini call failed for a reason the library does not classify.

Source

Thrown at sources/llm_provider.py:304

        """
        base_url = self.server_ip
        if self.is_local:
            raise Exception("Google Gemini is not available for local use. Change config.ini")

        client = OpenAI(api_key=self.api_key, base_url="https://generativelanguage.googleapis.com/v1beta/openai/")
        try:
            response = client.chat.completions.create(
                model=self.model,
                messages=history,
            )
            if response is None:
                raise Exception("Google response is empty.")
            thought = response.choices[0].message.content
            if verbose:
                print(thought)
            return thought
        except Exception as e:
            raise Exception(f"GOOGLE API error: {str(e)}") from e

    def together_fn(self, history, verbose=False):
        """
        Use together AI for completion
        """
        from together import Together
        client = Together(api_key=self.api_key)
        if self.is_local:
            raise Exception("Together AI is not available for local use. Change config.ini")

        try:
            response = client.chat.completions.create(
                model=self.model,
                messages=history,
            )
            if response is None:
                raise Exception("Together AI response is empty.")
            thought = response.choices[0].message.content

View on GitHub (pinned to ae57a23577)

Solutions

  1. Read the chained cause (the original exception message after 'GOOGLE API error:') to see the real failure
  2. Verify api_key and model in config.ini against Google AI Studio settings
  3. Check quota/rate limits in the Google Cloud console and network reachability to generativelanguage.googleapis.com
  4. Upgrade the openai SDK to a version compatible with Google's OpenAI-compatible endpoint
Defensive patterns

Strategy: try-catch

Validate before calling

if not api_key or not api_key.startswith("AI"):
    raise ValueError("invalid Google API key in config.ini")
if model not in KNOWN_GEMINI_MODELS:
    raise ValueError(f"unknown Gemini model: {model}")

Try / catch

try:
    thought = provider.google_fn(history)
except Exception as e:
    cause = e.__cause__
    logger.error("Google call failed: %s (cause: %s)", e, cause)
    if cause and hasattr(cause, "status_code") and cause.status_code == 429:
        thought = retry_with_backoff(lambda: provider.google_fn(history))
    else:
        raise

Prevention

When it happens

Trigger: Any exception inside the try block: client.chat.completions.create() raising an SDK/network/HTTP error, invalid api_key (401), invalid model name (404), response.choices empty (IndexError), or the None-response check firing.

Common situations: Expired/missing Google API key, wrong model name in config.ini, network timeouts, Google rate limits/quota exceeded, or SDK incompatibility with Google's OpenAI-compat endpoint.

Related errors


AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30). Data as JSON: /api/errors/66c94cf7798188b6. Report an issue: GitHub.