Commit Graph
11 Commits
Author SHA1 Message Date
Cesar GarciaandGitHub 999ffabc39 fix(gemini): use JSON instead of form-data for image edit requests (#18012)
* fix(gemini): use JSON instead of form-data for image edit requests

Gemini's image edit API expects JSON body, not multipart/form-data.
The handler was sending form-encoded data which caused 400 errors:
"Invalid JSON payload received. Unexpected token."

Changes:
- Add use_multipart_form_data() method to BaseImageEditConfig (default True)
- Modify image_edit_handler to use json= when use_multipart_form_data() is False
- Override use_multipart_form_data() in GeminiImageEditConfig to return False

* test(gemini): add test for use_multipart_form_data
2025-12-16 07:41:02 +05:30
nlinebackandGitHub e223cadb9f fix: add speechConfig to GenerationConfig for Gemini TTS (#17851)
Moved speechConfig from RequestBody to GenerationConfig TypedDict so that
TTS configuration survives the filtering in _transform_request_body().

This fixes the 400 INVALID_ARGUMENT error when using Gemini TTS models
(gemini-2.5-flash-tts, gemini-2.5-flash-preview-tts, etc.) with both
vertex_ai and gemini providers.

Fixes: speechConfig was being created correctly in map_openai_params()
but then filtered out because GenerationConfig.__annotations__.keys()
didn't include it.

Tested with both preview and non-preview TTS model names and both
vertex_ai and gemini providers.
2025-12-12 03:56:44 -08:00
Sameer KankuteandGitHub 018bd2e039 Add Gemini image edit support (#16430)
* Add gemini image edit support

* fix lint errors

* fix lint errors

* fix lint errors

* Add docs
2025-11-12 18:48:27 -08:00
Sameer KankuteGitHubCopilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>Ishaan Jaffer
e037d9315d Add Vertex and Gemini Videos API with Cost Tracking + UI support (#16323)
* Use video id for videos api

* remove mock code

* Potential fix for code scanning alert no. 3630: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* remove print statements

* Update video prefix for 'video_'

* Add veo with openai videos unified specs

* Add videos testing to UI

* remove mock code

* Remove not need ui changes:

* Fix mypy errors related to gemini

* fix test_transform_video_create_request

* Add vertex ai veo config

* Add vertex ai veo config

* Add cost tracking for gemini and add optional param passing

* fix bugs related to vertex ai veo

* Add Gemini Veo Video Generation in Openai Videos Unified Spec (#16229)

* Add veo with openai videos unified specs

* Add videos testing to UI

* remove mock code

* Remove not need ui changes:

* Fix mypy errors related to gemini

* fix test_transform_video_create_request

* Add contant video duration for gemini and vertex

* Fix litellm_mapped_tests tests

* fix azure videos issue

* Added doc for videos vertex ai

* fix seconds param error

* fix lint errors

* test_transform_video_create_response_cost_tracking_no_duration

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Ishaan Jaffer <ishaanjaffer0324@gmail.com>
2025-11-08 16:03:51 -08:00
fa175e8d90 Fix gemini cli error (#14417)
* Fix gemini cli error

* Added better handling

---------

Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
2025-09-12 11:56:51 -07:00
Sameer KankuteGitHubsameer@berri.ai <sameer@berri.ai>
1a123b2cd5 Litellm gemini cli bug fix (#14451)
* Fix gemini cli error

* Add reasoning request support

* Added better handling

* remove other PR code

* refactored code for better structure following

---------

Co-authored-by: sameer@berri.ai <sameer@berri.ai>
2025-09-12 11:55:26 -07:00
Ishaan JaffandGitHub afe159bb8b [Feat] GEMINI CLI Integration - Add /countTokens endpoint support (#13545)
* stash changes for token counter

* working TokenCountRequest

* working acount_tokens

* add GoogleAIStudioTokenCounter

* re-use validate_environment

* fixes count_tokens

* fixes google_count_tokens

* fixes token counter base class

* fix TokenCountResponse

* fix - use BaseTokenCounter

* add should_use_token_counting_api

* fixes for GoogleAIStudioTokenCounter

* fixes for should_use_token_counting_api

* fixes for google_count_tokens

* fixes for /messages count_tokens

* fixes for should_use_token_counting_api

* working e2e gemini token counter

* ruff check fixes

* fixes for token counter

* fixes for TokenCountResponse

* cleanup TokenCountRequest

* add TokenCountDetailsResponse

* fix use well typed Responses

* fix typing for TokenCountDetailsResponse

* test_vertex_ai_gemini_token_counting_with_contents

* fixes for TokenCountDetailsResponse

* test fixes

* test_factory_registration

* test_proxy_token_counter.py

* TestGoogleAIStudioTokenCounter

* fix token_counter
2025-08-12 16:19:58 -07:00
Siddharth SahuandGitHub 39d59f1900 Fix/gemini api key environment variable support (#12507)
* Fix: Add support for GOOGLE_API_KEY environment variables for Gemini API authentication

* added test cases

* incoperated feedback to make it more maintainable

* fix failed linting CI
2025-07-29 15:56:01 -07:00
Krish DholakiaandGitHub ee9dd158dd Fix - handle empty config.yaml + Fix gemini /models - replace models/ as expected, instead of using 'strip' (#12189)
* fix(proxy_server.py): handle empty config yaml

Fixes https://github.com/BerriAI/litellm/issues/12163

* fix(gemini/common_utils.py): replace models/ as expected, instead of using 'strip'

Fixes https://github.com/BerriAI/litellm/issues/12160

* fix(anthropic/experimental_pass_through/messages/transformation.py): check for env var when selecting api key

* docs(config_settings.md): add api key to docs
2025-06-30 21:56:03 -07:00
AyrennCandGitHub 8ae79178ae feat: Add audio parameter support to gemini tts models (#11287)
* feat: Add Gemini TTS audio parameter support

- Add is_model_gemini_audio_model() method to detect TTS models
- Include 'audio' parameter in supported params for TTS models
- Map OpenAI audio parameter to Gemini speechConfig format
- Add _extract_audio_response_from_parts() method to transform audio
  output to openai format

* updated unit-test to use pcm16

* - created typedict for speechconfig
- simplified gemini tts model detection
- moved gemini_tts test to test_litellm

* simplified is_model_gemini_audio_model more
2025-05-31 16:20:19 -07:00
Krish DholakiaandGitHub ef42461c1e Litellm fix GitHub action testing (#11163)
* test: add __init__.py files

* refactor: rename test folder to avoid naming conflict

* test: update workflows

* test: update tests

* test: update imports

* test: update tests

* test: remove unused import

* ci(test-litellm.yml): add pytest retry to github workflow

* test: fix test
2025-05-26 14:41:42 -07:00