Skip to content

Conversation

@Chesars
Copy link
Contributor

@Chesars Chesars commented Dec 5, 2025

Relevant issues

Fixes #17148

Pre-Submission checklist

  • I have Added testing in the tests/litellm/ directory
  • I have added a screenshot of my new test passing locally
  • 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

Summary

When using litellm.acompletion() with stream=True and a custom HTTP client, the client is not beign passed:

# This did NOT work - client was ignored
response = await litellm.acompletion(
    model="gemini/gemini-2.5-pro",
    messages=[...],
    client=custom_client,  # ❌ Ignored
    stream=True,
)

The sync version worked correctly:

# This worked fine
response = litellm.completion(
    model="gemini/gemini-2.5-pro",
    messages=[...],
    client=custom_client,  # ✅ Works
    stream=True,
)

Solution

Added gemini_client parameter to make_call() (async) to preserve the user's custom client, matching the existing pattern in make_sync_call() (sync).

Tests added

  • test_async_streaming_uses_custom_client
  • test_sync_streaming_uses_custom_client

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
@vercel
Copy link

vercel bot commented Dec 5, 2025

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

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Dec 5, 2025 7:53pm

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]: User specified async client is ignored with Gemini streaming+async

1 participant