Skip to content

Conversation

@Chesars
Copy link
Contributor

@Chesars Chesars commented Dec 26, 2025

Relevant issues

Fixes #18171

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

Summary

Adds snake_case support for Gemini/Vertex AI tool parameters to align with:

  • OpenAI API naming conventions (snake_case for function names)
  • PEP 8 Python style guide (snake_case for functions/variables)
  • Google's official Gemini API documentation
  • Existing LiteLLM patterns (e.g., google_maps, url_context)

When users follow Google's Gemini API documentation and use {"google_search": {}}, the tool parameter is ignored, causing a 400 error. This violates LiteLLM's core principle: "Call all LLM APIs using the OpenAI format".

Solution

Accept both snake_case and camelCase variants for tool names:

  • google_searchgoogleSearch
  • google_search_retrievalgoogleSearchRetrieval
  • enterprise_web_searchenterpriseWebSearch

Maintains backward compatibility - existing googleSearch calls continue to work.

Files Modified

  • litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py

    • Updated tool name matching to accept both snake_case and camelCase
    • Follows same pattern as google_maps (line 502-504)
  • tests/litellm/llms/vertex_ai/gemini/test_transformation.py

    • Added 4 comprehensive tests covering all tool variants

Users following official Google documentation should not receive errors. LiteLLM's job is to translate Python-style input → provider-native format, not force users to learn provider-specific naming conventions.

Documentation References


Note: This PR reopens the discussion from #18189. The implementation includes the same fixes with additional formatting improvements.

Add snake_case aliases for Gemini tool names to match the pattern
already used by other tools (url_context, google_maps, code_execution):
- google_search -> googleSearch
- google_search_retrieval -> googleSearchRetrieval
- enterprise_web_search -> enterpriseWebSearch
@vercel
Copy link

vercel bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
litellm Ready Ready Preview, Comment Dec 26, 2025 10:46pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: The Gemini's google_search tool parameters are ignored.

1 participant