litellm/tests/unit/llms/gemini
Mateo Wang 51f2796996
feat(gemini): send realtime reasoning effort as the Gemini Live thinking level (#55869)
* feat(gemini): send realtime reasoning effort as the Gemini Live thinking level

gemini/gemini-4-live picks its reasoning mode from setup.generationConfig.thinkingConfig.thinkingLevel,
but /v1/realtime dropped session.reasoning.effort. The cost map row now declares the levels Google
accepts, a declared level reaches Google, and an undeclared one is rejected unless drop_params is set

* test(vertex_ai): cover the realtime reasoning effort on the Vertex Live setup path

* fix(gemini): keep a Gemini Live turn left IN_PROGRESS and its answer in one realtime response

At medium and high thinking levels Gemini Live speaks a holding line, ends that turn with interactionStatus IN_PROGRESS, then answers in a second turn. The realtime transformation now closes the holding line's item, keeps the response open, gives the answer the next output index, and sends one response.done whose usage sums both turns. A session closed while a turn is still IN_PROGRESS bills that turn once, and a tool call during a holding line closes that line first

gemini/gemini-3.1-flash-live-preview and gemini/gemini-3.8-live-extended-thinking now list the thinking levels Google accepts for them, so a realtime reasoning effort reaches those models too

* fix(gemini): bill every Gemini Live tool turn and read thinking levels from the catalog row

A turn that ends with a bare turnComplete after a tool call now carries its usage into the next
response.done, so a model that speaks before the call, or calls it silently, is billed for both turns.
A per-modality entry without a tokenCount counts as 0 instead of dropping the whole breakdown.
Thinking levels come from the cost map row, never a router deployment's model_info copy, and a Live
model whose row lists no levels rejects a reasoning effort unless drop_params is set

A bill written when the session closes mid-response is labeled client_cancelled instead of turn_detected

* fix(gemini): read Live thinking levels only from the deployment's own provider row

A Vertex AI Live deployment fell back to the Google AI Studio row and sent its
thinking level to Vertex. The level list now comes only from the row of the
provider the deployment runs on

The error for an effort on a model with no listed levels now says LiteLLM lists
none, since Google can still think on those models

Adds a regression test for a barge-in during the answer that follows a holding
line, built from the frames Gemini Live sends

* fix(gemini): give a question asked during the Live thinking pause its own response

* refactor(gemini): drop the realtime reasoning param no code reads

* fix(gemini): end an interrupted realtime turn as cancelled when Gemini keeps thinking
2026-12-04 16:23:19 -08:00
..
audio_transcription fix(audio-transcription): keep transcripts out of transcription error messages (#50137) 2026-11-05 18:07:15 -08:00
batches feat(gemini): file-backed batch jobs on /v1/batches with output download and spend tracking (#51032) 2026-11-11 12:00:32 -08:00
decisions fix(decisions): keep systemone confidence, extra fields and proxy cost on litellm_proxy calls (#53195) 2026-11-21 12:47:10 -08:00
files feat(gemini): support extended multimodal file inspection on chat completions (#52611) 2026-11-23 19:17:35 -08:00
google_genai fix(guardrails): check one-object parts and tool turns on generateContent (#54359) 2026-11-25 12:32:47 +00:00
image_edit fix(vertex_ai): honor Gemini image size and imageConfig controls on generation and edits (#53580) 2026-11-23 09:05:25 -08:00
image_generation refactor(vertex_ai)!: remove the retired Google Imagen image translators (#55892) 2026-12-02 19:25:12 -08:00
realtime feat(gemini): send realtime reasoning effort as the Gemini Live thinking level (#55869) 2026-12-04 16:23:19 -08:00
vector_stores refactor(typing): clear 102 basedpyright Any errors across 21 files (#54586) 2026-11-25 19:03:46 -08:00
videos refactor(cost): consolidate pricing modules (#56131) 2026-12-04 23:14:04 +00:00
__init__.py test(unit): make every tests/unit directory a package so pytest collection is unique 2026-09-20 11:50:59 +00:00
test_empty_image_response.py fix(gemini): return an error instead of an empty 200 when a Gemini image request gets no image (#29125) 2026-11-25 20:55:23 +00:00
test_gemini_client_setup.py chore(cost-map): remove the 52 rows whose provider retired them before 2026 (#49974) 2026-11-03 16:23:06 -08:00
test_gemini_common_utils.py fix(proxy): count a contents-only body on /utils/token_counter (#50710) 2026-11-26 01:21:21 +00:00
test_gemini_image_generation_transformation.py refactor(vertex_ai)!: remove the retired Google Imagen image translators (#55892) 2026-12-02 19:25:12 -08:00
test_gemini_streaming.py test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00
test_gemini_tts.py fix(gemini)!: answer 400 for an unsupported chat audio format, drop it under drop_params (#49423) 2026-11-02 04:33:19 -08:00
test_image_usage_transformation.py fix(images): normalize null cached token counts (#52857) 2026-11-19 17:49:26 +00:00