Fix: User specified async client ignored with Gemini streaming+async - #17550
Merged
Chesars merged 1 commit intoMar 4, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryFixes a bug where user-specified async HTTP clients were silently ignored during Gemini streaming + async calls (
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py | Adds gemini_client parameter to make_call() async function, mirroring the existing make_sync_call() pattern to ensure user-specified async clients are passed through for streaming calls. |
| tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py | Adds two tests verifying gemini_client is passed through partial() keywords for both async and sync streaming paths. Tests are shallow — they verify partial wiring but don't invoke the actual functions. |
Sequence Diagram
sequenceDiagram
participant User as User Code
participant AC as litellm.acompletion()
participant AS as VertexLLM.async_streaming()
participant CSW as CustomStreamWrapper
participant MC as make_call()
participant Client as HTTP Client
User->>AC: acompletion(stream=True, client=custom_client)
AC->>AS: async_streaming(client=custom_client)
AS->>CSW: CustomStreamWrapper(make_call=partial(make_call, gemini_client=custom_client, ...))
Note over CSW: Stores partial for lazy invocation
CSW->>MC: await make_call(client=module_level_aclient)
alt gemini_client is not None
MC->>MC: client = gemini_client (user's client wins)
end
MC->>Client: client.post(api_base, stream=True)
Client-->>MC: streaming response
MC-->>CSW: ModelResponseIterator
CSW-->>User: async stream chunks
Last reviewed commit: 872554d
The user-specified async client was being overwritten by `litellm.module_level_aclient` in `streaming_handler.py` when using async+streaming with Gemini. This fix adds a `gemini_client` parameter to `make_call()` (matching the existing pattern in `make_sync_call()`) so the user's custom client is preserved and not overwritten. Fixes BerriAI#17148
Chesars
force-pushed
the
fix/gemini-async-streaming-custom-client-17148
branch
from
March 4, 2026 22:38
64ef649 to
872554d
Compare
Chesars
merged commit Mar 4, 2026
d346f5c
into
BerriAI:litellm_oss_staging_03_04_2026
4 of 5 checks passed
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
…ing-custom-client-17148 Fix: User specified async client ignored with Gemini streaming+async
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Fixes #17148
Pre-Submission checklist
tests/litellm/directorymake test-unitType
🐛 Bug Fix
Summary
When using
litellm.acompletion()withstream=Trueand a custom HTTP client, the client is not beign passed:The sync version worked correctly:
Solution
Added
gemini_clientparameter tomake_call()(async) to preserve the user's custom client, matching the existing pattern inmake_sync_call()(sync).Tests added
test_async_streaming_uses_custom_clienttest_sync_streaming_uses_custom_client