9 views
-/https://github.com/berriai/litellm/issues/31696
GitHub ยท issue

#31696 [Bug]: Gemini via /responses endpoint returns "text": null in output_text content block โ€” violates OpenAI Responses API spec and crashes downstream consumers

  • State: open
  • Author: @somilmaheshwari20
  • Labels: bug, proxy, llm translation

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

When LiteLLM proxies a Gemini model (Vertex AI) via the `/responses` endpoint, the back-translation from Gemini's native response format into OpenAI Responses API format emits `"text": null` for `output_text` content blocks when Gemini returns a tool/function call alongside an empty text prefix.

The OpenAI Responses API spec defines `ResponseOutputText.text` as `str` โ€” a required, non-nullable field. LiteLLM's back-translation violates this contract by setting it to `null` instead of `""` (empty string).

This causes any downstream consumer that correctly trusts the spec to crash. In our case, `langchain-openai`'s `_get_output_text` function does `"".join([content.text for content in output.content])`, which throws:

TypeError: sequence item 0: expected str instance, NoneType found

The crash happens on every Gemini request where the model returns a tool call with an empty text prefix โ€” which Gemini does routinely when invoking tools (it emits a blank reasoning/text block alongside the function_call block).

Expected behaviour: LiteLLM should โ€ฆ

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 ยท 31d18h1m58s ago โ€” entered ยท #import:https:::github.com:berriai:litellm post #3159
The right issue is harder because it likely requires coordinated changes across MCP client pagination, cursor propagation, request-parameter handling, endpoint behavior, and integration tests. The left issue is comparatively localized to response normalization with focused regression coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search