litellm/tests/unit/llms/vertex_ai
mika-lt 9799ad743d
fix(gemini): return raw pcm16 when Gemini TTS answers WAV audio (#51145)
* fix(gemini): return raw pcm16 when Gemini TTS answers WAV audio

* fix(gemini): unwrap only pcm16-shaped WAV and pass through audio it cannot read

Lyria music asked for as WAV is 48 kHz stereo, so stripping its header lost the rate and channels. Only a 24 kHz mono 16-bit WAV is unwrapped now, and audio that fails to decode or parse comes back unchanged instead of raising.

* fix(gemini): decode WAV audio strictly and stop double-wrapping WAV on speech

Pass through audio/wav base64 that is not strict base64, including non-ASCII and URL-safe input, unwrap WAV sent as a data URI text part, and return audio that is already a WAV container from /v1/audio/speech as is

* fix(gemini): keep audio the caller asked Gemini for and read WAV headers from a prefix

A responseFormat.audio.mimeType request now returns Gemini's audio as is, audio/x-wav, audio/wave and audio/vnd.wave labels unwrap like audio/wav, and a WAV of another shape is no longer decoded in full.

* fix(gemini): keep the audio a caller asks for through extra_body or a mime_type key

A responseFormat.audio.mime_type, or a responseFormat sent through extra_body.generationConfig, now counts as an explicit ask the same as mimeType. A responseFormat whose audio names no mime type still returns raw PCM

* fix(gemini): pick the audio passthrough from the responseFormat Gemini receives

An extra_body.generationConfig responseFormat, or response_format, replaces the top-level responseFormat on the request, so the response side now reads that same value before deciding to keep Gemini's audio as is

* fix(gemini): decide the audio passthrough from the request body Gemini receives

The keep-or-unwrap choice for Gemini TTS chat audio now reads generationConfig.responseFormat (or response_format) from the body sent to Gemini, so a dropped or overridden extra_body value no longer flips it, and a mime type given as its enum number counts as an ask

* fix(gemini): read snake_case generation_config, treat enum 0 as unset, and keep the audio Google sent on batch, native and pass-through logs

* fix(vertex_ai): keep transforming a batch output row whose request is not an object

* fix(gemini): read snake_case generation_config when the camelCase key is null

Gemini accepts a null generationConfig next to a snake_case generation_config and answers with the audio format the snake_case key names, so the keep-or-unwrap check now falls through to it.

* fix(gemini): key cached responses on the requested audio format

Whether Gemini TTS audio comes back as raw PCM now depends on the audio mime
type a request names under responseFormat, generationConfig, or
generation_config. The response cache key left those out, so a cached PCM
answer could serve a later AUDIO_WAV ask, and a cached WAV answer could serve
a call that named no format. The cache key now includes them, top level and
under extra_body.

A float mime type such as 4.0 is matched like its enum number, and the native
generateContent pricing copy keeps Google's audio, since it only reads usage.

* refactor(gemini): log chat and pass-through responses through one helper

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-24 08:45:12 -08:00
..
agent_engine fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
audio_transcription feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
batches feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
context_caching fix(gemini): keep an empty trailing user turn so Gemini doesn't answer a model-turn 400 (#51311) 2026-11-23 15:45:29 -08:00
count_tokens ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
files fix(gemini): return raw pcm16 when Gemini TTS answers WAV audio (#51145) 2026-11-24 08:45:12 -08:00
fine_tuning fix(managed_files): send provider file ids when creating a fine-tuning job from managed files (#46552) 2026-10-19 14:40:15 -07:00
fixtures test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
gemini fix(gemini): return raw pcm16 when Gemini TTS answers WAV audio (#51145) 2026-11-24 08:45:12 -08:00
gemini_embeddings fix(vertex_ai): answer 400 for gemini embedding video_metadata that samples no frames (#54086) 2026-11-24 05:02:14 -08: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 fix(vertex_ai): honor Gemini image size and imageConfig controls on generation and edits (#53580) 2026-11-23 09:05:25 -08:00
interactions feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
multimodal_embeddings feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
rag_engine fix(vertex_ai): keep legacy bucket_name in credential resolution and add GCS_BATCH_BUCKET_NAME env var (#42803) 2026-09-25 15:32:21 -07:00
realtime feat(gemini): support Gemini Live Avatar on Vertex AI realtime (#53270) 2026-11-21 15:06:59 -08:00
rerank feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
responses feat(vertex_ai): add Meta Muse models on Vertex AI (#50768) 2026-11-21 13:00:24 -08:00
text_to_speech fix(vertex_ai): honor vertex_location for the Cloud Text-to-Speech endpoint (#50255) 2026-11-06 00:03:17 -08:00
vertex_ai_partner_models fix(anthropic): drop unsigned thinking blocks before /v1/messages reaches Claude (#51793) 2026-11-24 05:30:55 +00:00
vertex_embeddings fix(logging): stop keeping a full response copy nobody reads (#52524) 2026-11-18 11:51:01 -08:00
vertex_gemma_models fix(streaming)!: send the include_usage chunk with an empty choices array (#47109) 2026-10-21 02:26:05 +00:00
videos feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
__init__.py test: migrate legacy provider tests to tests/unit (wave 2, phase 13) 2026-09-20 14:18:49 +00:00
google_genai_proxy_test_config.yaml test: move whole-unit legacy test files into tests/unit and delete dead skips (#44807) 2026-10-07 05:02:28 +00:00
test_bge_embedding.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_bge_response_transformation.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_common_utils.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_gemini_batch_embeddings.py feat(gemini): accept file content blocks with video_metadata on multimodal embeddings (#45305) 2026-10-08 13:20:03 -07:00
test_gemini_empty_properties.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_gemini_header_forwarding.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_http_status_201.py fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
test_request_labels.py feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
test_vertex.py feat(messages): serve vertex ai claude messages on rust only (#52314) 2026-11-19 21:15:10 +00:00
test_vertex_ai_batch_transformation.py test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
test_vertex_ai_common_utils.py fix(vertex_ai): pin const values on Gemini tool and response schemas (#53413) 2026-11-22 18:27:58 +00:00
test_vertex_ai_non_gemini.py fix(vertex): report an unreadable credentials file as a read failure (#40173) 2026-10-15 02:03:56 -07:00
test_vertex_ai_psc_endpoint_support.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_vertex_ai_search_vector_store_transformation.py test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940) 2026-10-11 06:24:57 -07:00
test_vertex_gemini_gcs_uri_mime.py fix: preserve media across Responses and Gemini conversions (#48484) 2026-10-27 18:07:10 -07:00
test_vertex_global_url_support.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_vertex_image_generation.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_vertex_llm_base.py feat(bedrock): derive STS session tags and session name from caller identity (#52978) 2026-11-19 17:11:09 -08:00
test_vertex_model_garden_openapi.py fix(openai_like): honor the deployment timeout and stream_timeout on async streams (#53442) 2026-11-22 21:52:59 +00:00
test_vertex_passthrough_logging_handler.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00