Skip to content

[Bug]: Proxy: Gemini empty responses don't trigger fallbacks #14655

@phemmer

Description

@phemmer

What happened?

Gemini has a fairly common tendency to produce empty responses (all models, pro, flash, flash-lite) (#10721 and https://discuss.ai.google.dev/t/gemini-2-5-pro-with-empty-response-text/81175/123). This seems to come in waves. Meaning I'll start experiencing the issue a lot for a period of time, and then it resolves. So this seems to be indicative of some sort of issue on the server side.

The problem is that these responses are considered as a "success" by LiteLLM, which prevents fallback models from kicking in. This is what I believe needs to be addressed. When the model returns a completely empty response, this should be considered a failure condition, and a fallback model should be invoked.

Relevant log output

{
  "id": "1FTLaK38Ec3Vz7IPkbOIWA",
  "model": "gemini-2.5-flash-lite",
  "usage": {
    "total_tokens": 4083,
    "prompt_tokens": 4083,
    "completion_tokens": 0,
    "prompt_tokens_details": {
      "text_tokens": 4083,
      "audio_tokens": null,
      "image_tokens": null,
      "cached_tokens": null
    },
    "completion_tokens_details": {
      "text_tokens": null,
      "audio_tokens": null,
      "reasoning_tokens": 0,
      "accepted_prediction_tokens": null,
      "rejected_prediction_tokens": null
    }
  },
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [],
        "function_call": null
      },
      "finish_reason": "stop"
    }
  ],
  "created": 1758155988,
  "system_fingerprint": null
}

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

Whatever is container image b1cab7d09edd2b9c9e0634ad4ba5008a88793dc3b9aac8a40a52d312436b15ad / sha256:3425d9d76327eda5423c419af9bd37c1fbc94014bf980c7b6a15e78a69ced58e

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions