Skip to content

Run pre_call_hook on Google generateContent endpoints - #26914

Merged
Michael-RZ-Berri merged 1 commit into
litellm_internal_stagingfrom
litellm_googleGenContentHooks
May 1, 2026
Merged

Run pre_call_hook on Google generateContent endpoints#26914
Michael-RZ-Berri merged 1 commit into
litellm_internal_stagingfrom
litellm_googleGenContentHooks

Conversation

@Michael-RZ-Berri

Copy link
Copy Markdown
Contributor

Relevant issues

Adds a hook onto the google generateContent endpoints like everywhere else in the code base.

Linear ticket

Resolves LIT-2706

Pre-Submission checklist

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

  • I have Added testing in the tests/test_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
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Added test that go through guardrails fails before and passes after.

Type

🧹 Refactoring
✅ Test

Changes

Changes google_endpoints/endpoints.py

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Michael Riad Zaky seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors the google_generate_content and google_stream_generate_content endpoints to delegate through ProxyBaseLLMRequestProcessing.base_process_llm_request, bringing them in line with the rest of the proxy and enabling the full pre_call_hook / guardrail pipeline. The generationConfig → config field mapping is moved from the endpoint handlers into route_request in route_llm_request.py, and new tests in test_route_llm_request.py verify the transformation at that layer.

Confidence Score: 5/5

Safe to merge — the refactor is consistent with existing proxy patterns and no regressions were identified.

Only a P2 test-gap finding; no P1 or P0 issues found. Core change correctly routes through the hook pipeline.

tests/test_litellm/proxy/test_route_llm_request.py — minor assertion gap in test_route_request_preserves_existing_config_for_google_routes

Important Files Changed

Filename Overview
litellm/proxy/google_endpoints/endpoints.py Both google_generate_content and google_stream_generate_content now delegate to ProxyBaseLLMRequestProcessing.base_process_llm_request, enabling the full pre/during/post-call hook pipeline (including guardrails); generationConfig → config mapping moved to route_request.
tests/test_litellm/proxy/google_endpoints/test_google_api_endpoints.py Tests refactored to mock at the ProxyBaseLLMRequestProcessing level; previous end-to-end assertions replaced with processor-invocation checks; coverage of generationConfig → config transformation moved to test_route_llm_request.py.
tests/test_litellm/proxy/test_route_llm_request.py New parametrized tests verify generationConfig → config mapping and preservation logic in route_request; minor gap: the "preserve existing config" test doesn't assert generationConfig is removed from forwarded kwargs.

Reviews (2): Last reviewed commit: "run pre_call_hook on Google generateCont..." | Re-trigger Greptile

@Michael-RZ-Berri
Michael-RZ-Berri force-pushed the litellm_googleGenContentHooks branch from 74d1231 to 0ac1e25 Compare April 30, 2026 20:10
@Michael-RZ-Berri

Copy link
Copy Markdown
Contributor Author

@greptile-ai

@Michael-RZ-Berri
Michael-RZ-Berri force-pushed the litellm_googleGenContentHooks branch from 0ac1e25 to 2a2e9d8 Compare April 30, 2026 23:02
@Michael-RZ-Berri
Michael-RZ-Berri force-pushed the litellm_googleGenContentHooks branch from 2a2e9d8 to 053e040 Compare April 30, 2026 23:44
@Michael-RZ-Berri
Michael-RZ-Berri merged commit e4fb325 into litellm_internal_staging May 1, 2026
114 of 116 checks passed
@Michael-RZ-Berri
Michael-RZ-Berri deleted the litellm_googleGenContentHooks branch May 1, 2026 00:53
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…tHooks

Run pre_call_hook on Google generateContent endpoints
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.

3 participants