Repository navigation
fix(bridges): refuse audio output on Responses, Messages and Completions before the provider call - #49960
Conversation
…ons before the provider call These surfaces bridge to chat completions and cannot carry audio output, so a Gemini TTS model or an audio or modalities ask returned 200 with empty output while billing audio tokens. They now answer 400 before any provider call, and drop_params strips the audio ask instead
Merging this PR will not alter performance1 warning
Comparing Footnotes |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…/v1/completions bridges These endpoints bridge into chat completions, and their response shapes cannot carry message.audio. A model that answers only in audio, or a request that asks for audio, used to return an empty 200 while the audio was still billed. The bridges now answer 400 UnsupportedParamsError before any provider call. A request that asks for audio can opt out with drop_params or additional_drop_params, which drops audio and removes "audio" from modalities. /v1/chat/completions is unchanged.
…odule Brings the branch up to 5bc25ff and takes the tree of the reworked fix, which also refuses Gemini models whose cost map row answers audio and not text (the Lyria rows), and shares that cost map read with the Gemini max output tokens check
|
bugbot run |
[Medium impact] The PR appears safe to merge with no new blocking findings.
|
…y models The full model info lookup can fetch a Hugging Face model config or call a provider's model info API on every bridged text request. The audio-only check only needs the catalog's supported_output_modalities
|
bugbot run |
…eeps answering text The cost map lists only audio output for the Lyria rows, but Gemini also sends their lyrics as text, so refusing them turned a working 200 into a 400. The audio request refusal now names the param to leave out next to drop_params and /v1/chat/completions
|
bugbot run |
A model asked for audio it cannot produce got told to call /v1/chat/completions, which returns no audio for it either. The refusal now only names the params to leave out and drop_params Tests also check that the Lyria lyrics reach the caller and that a request sending both audio and modalities names both
|
bugbot run |
…udio 400 The 400 for an audio request on the Responses, Messages and text completion bridges now tells callers whose model can return audio to call /v1/chat/completions to get it
The audio-only refusal on the Responses, Messages and text completion bridges now applies only when the provider is gemini, vertex_ai or vertex_ai_beta, where LiteLLM's own Gemini transformation turns a TTS model's answer into audio. A deployment on another provider whose name happens to contain gemini and tts, such as a custom_openai one, reaches its upstream as before
|
bugbot run |
|
Closed to free an open-PR slot. Branch kept. Reopen with |
…dio_bridges # Conflicts: # litellm/llms/anthropic/messages/native/handler.py
…ints The bridged endpoints now refuse a Gemini TTS deployment before the provider call, so the integration test that expected a 200 with the deployment voice asserted the old empty, billed answer. It now checks the 400, the endpoint named in the error, and that the scripted peer got no request
A request asking for audio on the bridged endpoints drops it when the global litellm.drop_params is on. No test covered that path, so a check that only read the request's own drop_params passed every case
|
bugbot run |
…dio_bridges # Conflicts: # litellm/responses/main.py
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5620c61. Configure here.
…ons before the provider call Backport of #49960 to lts/1.108.x, folding its commits into one adapted commit The /v1/messages check goes in litellm/llms/anthropic/pass_through/messages/handler.py, where this line keeps the chat bridge. The line has no litellm.utils.is_gemini_tts_model, so this adds the same name check main got in #31915. text_completion keeps the line's **optional_params spread The test fixture drops register_model's add_to_provider_model_sets flag, which this line does not have Cherry-picked from ec882be, c37c252, 9b6b65e, 16255e8, 675bf5d, 3d505a2, 22777c8, 3c5ed0a, a345bc4 (litellm_fix_gemini_audio_bridges)
fix(bridges): backport #49960 audio output refusal to lts/1.108.x
Handwritten 1-3 sentence description
Gemini TTS models only answer with audio, and /v1/responses, /v1/messages and /v1/completions have nowhere to put it, so callers got an empty 200 and still paid for the audio. Those endpoints now return a 400 pointing to /v1/chat/completions before anything is sent to the provider. A request that asks for audio on them through
audioormodalitiesgets a 400 too, unless drop_params is on, in which case the audio part is droppedDetails
TLDR
Problem this solves:
How it solves it:
Intentional product change: a text model asked for audio on these endpoints now answers 400 unless drop_params is on
User Flow
Before: a developer who calls a Gemini TTS model through /v1/responses gets an empty answer and still pays for it
"model": "gemini-tts"and"audio": {"voice": "Kore", "format": "pcm16"}, or the same through /v1/messages or /v1/completions"output": []("content": []on /v1/messages,"text": nullon /v1/completions)After: the same request is refused before it reaches Gemini, so nothing is billed
gemini/gemini-3.8-flash-tts returns audio, which /v1/responses cannot carry. Call /v1/chat/completions to get the audio.Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or moreDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Last updated: 5620c61, which merges main c4b915b into this PR. QA ran again on both, before on c4b915b and after on 5620c61
Both legs ran the same client against a live 2-worker proxy with its own Postgres. Every call hit Gemini, Vertex or Azure
How to run it
Run from the checked-out commit's root with
GEMINI_API_KEY,AZURE_LIT6549_AUDIO_QA_API_BASE,AZURE_LIT6549_AUDIO_QA_API_KEY,VERTEXAI_PROJECT,GOOGLE_APPLICATION_CREDENTIALS,LITELLM_MASTER_KEYandDATABASE_URLin.envRedis and
--reloadare left out because the check keeps no state between requests and each leg has to stay on its commit. Each proxy logged two worker processes, 1644027 and 1644028 before, 1644034 and 1644035 after$CONFIGis the file below, with nodrop_paramsConfig
litellm-qa-gpt-audio-miniis an Azure gpt-audio-mini 2025-10-06 deployment. The run also pointed the Gemini deployments'api_baseat a recording proxy that forwards each request to Gemini unchangedWith
PROXYandLITELLM_MASTER_KEYexported, the client sends one prompt to all four endpoints through the official SDKs.gemini-ttssendsaudio,gemini-flashsendsmodalities,gemini-lyriasends neither,azure-gpt-audiosends both, anddropaddsdrop_params: trueclients.py
Before (c4b915b)
Gemini TTS on each endpoint
The three bridges answer 200 with nothing in them and bill the audio
Lyria and Gemini Flash
Lyria answers lyrics, Gemini Flash answers text with or without drop_params
gpt-audio asking for audio
/v1/messages and /v1/completions answer 200 with nothing in them, with or without drop_params
Prompt template asking for audio
Gemini gets responseModalities [TEXT, AUDIO] with or without drop_params
The recording proxy saw two Gemini requests, both with
responseModalities: ["TEXT", "AUDIO"]. Under each command is its status line with LiteLLM's call id and cost headersSpend logs
Every bridged Gemini TTS and gpt-audio call is a billed success
Vertex AI TTS
Vertex rejects the request with its own 400 after the call, and chat completions returns audio
Ran with
VERTEXAI_PROJECTand a service account key inGOOGLE_APPLICATION_CREDENTIALSAfter (5620c61)
Gemini TTS on each endpoint
The three bridges answer 400 before the call, and chat completions still returns audio
Lyria and Gemini Flash
Lyria still answers lyrics, Gemini Flash asking for audio gets 400 unless drop_params is on
gpt-audio asking for audio
/v1/messages and /v1/completions answer 400 before the provider call, and Azure answers 400 once audio is dropped
Prompt template asking for audio
400 before the call, and drop_params sends [TEXT]
The recording proxy saw one Gemini request, for the drop_params call, with
responseModalities: ["TEXT"]Spend logs
The refused calls are failures with 0 spend, everything else is unchanged
Vertex AI TTS
LiteLLM answers 400 before the call, and chat completions still returns audio
Same deployment and credentials as the before leg
What the run showed next to the fix
text: nullDecisions
/v1/chat/completionsreturns the clipaudio, ormodalitiescontaining "audio". Following the usual convention, it answers 400 unlessdrop_paramsis on, oradditional_drop_paramsnames the param. That holds for text models too, since the caller asked for something the endpoint cannot returnaudioand takes "audio" out ofmodalities, removingmodalitieswhen nothing is left/v1/messagesforopenai/models goes through the Responses API instead of chat completions, so this PR does not touch that path. Azure's Responses API rejected gpt-audio with its own 400 in this runextra_body={"audio": ...}on the Python SDK'slitellm.responses()is not checked. On the proxy those keys arrive at the top level and are coveredaudionow get this 400 instead of the 500 TypeError they returned beforetests/unit/litellm_core_utils/test_bridged_audio_output.py. They send real HTTP to a respx route, and removing any one endpoint's check fails 10 of that endpoint's 15 cases, and removing the provider gate or either Vertex provider from it fails 3allowed_openai_paramsdoes not skip this check. It says which params a provider accepts, while the problem here is the endpoint, whose response has no field for audio whatever the provider returns/live-pr-risk at 5620c61
No regression outside the change this PR names. Base c4b915b and head ran 23 cells on 2-worker proxies with their own Postgres and a recording proxy in front of real Gemini, and the QA client above ran on both
Breaking
modalitiesasks for audio gets the same 400 on /v1/responses, sync and streaming. With drop_params, Gemini gets[TEXT]instead of[TEXT, AUDIO]allowed_openai_params: ["audio"]does not skip the refusal. Kept on purpose, see DecisionsBackward incompatible
Regression risk
[TEXT, AUDIO]on both legs/v1/messagesfor openai/ models on the Responses route is not checked, see DecisionsDependency graph. The three call sites, templates on /v1/responses, spend logs and the upstream request were driven live. A template without audio params sent the same request on both legs, and every cell made one upstream attempt. The Gemini TTS wire file passed 27 of 27 and the prompt routes file 18, 1 skipped as a known bug on main
Not verified. The A2A bridge, the Interactions API, batches and health checks were read, not driven
Type
🐛 Bug Fix
Caveats (if any)
Medium
modalitieswith "audio" answered 200 with text before. It answers 400 nowdrop_params: truebrings back the old answerLow
audioormodalitiesskips the check on /v1/messagesfallback_on_unsupported_paramsdefaults to true, so "nothing is billed" holds only when no fallback is configuredaudioormodalitiescomes from a deployment'slitellm_params, the caller is told to leave out params they never sentextra_bodyaudio onlitellm.responses()skips the checkmodalities: ["text", "audio"]andaudioFinal Attestation
Bugbot summary