Fosowl/agenticSeek · error · Exception
Google response is empty.
Error message
Google response is empty.
What it means
google_fn() checks that the OpenAI-compatible client returned a non-null response from chat.completions.create and raises this error when the response is None. It guards against dereferencing response.choices[0].message.content on an empty reply. The raise is immediately re-wrapped by the outer except as 'GOOGLE API error: Google response is empty.'
Source
Thrown at sources/llm_provider.py:298
except Exception as e:
raise Exception(f"Anthropic API error: {str(e)}") from e
def google_fn(self, history, verbose=False):
"""
Use google gemini to generate text.
"""
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(View on GitHub (pinned to ae57a23577)
Solutions
- Check network connectivity/proxy settings toward generativelanguage.googleapis.com
- Verify the model name in config.ini is a valid Gemini model (e.g. gemini-1.5-pro)
- Upgrade the openai SDK and ensure the Google OpenAI-compatible base URL is current
- Retry the request; if persistent, add logging of the raw HTTP response
Example fix
// before
response = client.chat.completions.create(model=self.model, messages=history)
thought = response.choices[0].message.content
// after
response = client.chat.completions.create(model=self.model, messages=history)
if not response or not response.choices:
raise Exception("Google response is empty or malformed.")
thought = response.choices[0].message.content or "" Defensive patterns
Strategy: type-guard
Validate before calling
cfg = load_config()
if not cfg.get("google", {}).get("model"):
raise ValueError("google model missing in config.ini")
if not reachable("https://generativelanguage.googleapis.com"):
raise ConnectionError("cannot reach Google API") Type guard
def is_valid_completion(response) -> bool:
return (
response is not None
and getattr(response, "choices", None)
and response.choices[0].message is not None
and response.choices[0].message.content is not None
) Try / catch
try:
thought = provider.google_fn(history)
except Exception as e:
if "response is empty" in str(e):
thought = retry_with_backoff(lambda: provider.google_fn(history))
else:
raise Prevention
- Retry transient empty responses with backoff
- Pin and periodically upgrade the openai SDK
- Monitor Google API status/quota before batch runs
When it happens
Trigger: client.chat.completions.create(...) against generativelanguage.googleapis.com returns None instead of a ChatCompletion object — e.g. silent transport failure or SDK returning null on an empty response.
Common situations: Network/proxy issues causing empty replies, Google API returning an empty body (quota/rate-limit edge cases), incorrect model name in config.ini leading to a degenerate response, or outdated OpenAI SDK version against Google's OpenAI-compat endpoint.
Related errors
- Together AI response is empty.
- OpenAI response is empty.
- Anthropic response is empty.
- Google Gemini is not available for local use. Change config.
- GOOGLE API error: {str(e)}
AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30).
Data as JSON: /api/errors/66cce54c66f53ad8.
Report an issue: GitHub.