{"record":{"id":"66c94cf7798188b6","repo":"Fosowl/agenticSeek","slug":"google-api-error-str-e","errorCode":null,"errorMessage":"GOOGLE API error: {str(e)}","messagePattern":"GOOGLE API error: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/llm_provider.py","lineNumber":304,"sourceCode":"        \"\"\"\n        base_url = self.server_ip\n        if self.is_local:\n            raise Exception(\"Google Gemini is not available for local use. Change config.ini\")\n\n        client = OpenAI(api_key=self.api_key, base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\")\n        try:\n            response = client.chat.completions.create(\n                model=self.model,\n                messages=history,\n            )\n            if response is None:\n                raise Exception(\"Google response is empty.\")\n            thought = response.choices[0].message.content\n            if verbose:\n                print(thought)\n            return thought\n        except Exception as e:\n            raise Exception(f\"GOOGLE API error: {str(e)}\") from e\n\n    def together_fn(self, history, verbose=False):\n        \"\"\"\n        Use together AI for completion\n        \"\"\"\n        from together import Together\n        client = Together(api_key=self.api_key)\n        if self.is_local:\n            raise Exception(\"Together AI is not available for local use. Change config.ini\")\n\n        try:\n            response = client.chat.completions.create(\n                model=self.model,\n                messages=history,\n            )\n            if response is None:\n                raise Exception(\"Together AI response is empty.\")\n            thought = response.choices[0].message.content","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/Fosowl/agenticSeek/blob/ae57a2357745a9706cb12d0fd76d954c84d166fa/sources/llm_provider.py#L286-L322","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the chained cause (the original exception message after 'GOOGLE API error:') to see the real failure","Verify api_key and model in config.ini against Google AI Studio settings","Check quota/rate limits in the Google Cloud console and network reachability to generativelanguage.googleapis.com","Upgrade the openai SDK to a version compatible with Google's OpenAI-compatible endpoint"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if not api_key or not api_key.startswith(\"AI\"):\n    raise ValueError(\"invalid Google API key in config.ini\")\nif model not in KNOWN_GEMINI_MODELS:\n    raise ValueError(f\"unknown Gemini model: {model}\")","typeGuard":null,"tryCatchPattern":"try:\n    thought = provider.google_fn(history)\nexcept Exception as e:\n    cause = e.__cause__\n    logger.error(\"Google call failed: %s (cause: %s)\", e, cause)\n    if cause and hasattr(cause, \"status_code\") and cause.status_code == 429:\n        thought = retry_with_backoff(lambda: provider.google_fn(history))\n    else:\n        raise","preventionTips":["Always inspect __cause__ on this wrapper error","Handle 401/404/429 causes distinctly (key, model, quota)","Pre-flight check api_key and model name before running jobs"],"tags":["api-error","gemini","error-wrapper"],"backgroundTag":"upstream-api-error","analyzedSha":"ae57a2357745a9706cb12d0fd76d954c84d166fa","analyzedAt":"2026-08-30T02:49:05.834Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}