Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix: google_genai streaming adapter provider handling (#18845)

mel2oo7161f41746db
diff --git a/litellm/google_genai/main.py b/litellm/google_genai/main.py
index b7523ef8c16..1dc805a6b54 100644
--- a/litellm/google_genai/main.py
+++ b/litellm/google_genai/main.py
@@ -130,6 +130,9 @@ class GenerateContentHelper:
api_key=litellm_params.api_key,
)
+ if litellm_params.custom_llm_provider is None:
+ litellm_params.custom_llm_provider = custom_llm_provider
+
# get provider config
generate_content_provider_config: Optional[
BaseGoogleGenAIGenerateContentConfig
@@ -407,6 +410,9 @@ async def agenerate_content_stream(
# Check if we should use the adapter (when provider config is None)
if setup_result.generate_content_provider_config is None:
+ if "stream" in kwargs:
+ kwargs.pop("stream", None)
+
# Use the adapter to convert to completion format
return (
await GenerateContentToCompletionHandler.async_generate_content_handler(
@@ -490,6 +496,9 @@ def generate_content_stream(
# Check if we should use the adapter (when provider config is None)
if setup_result.generate_content_provider_config is None:
+ if "stream" in kwargs:
+ kwargs.pop("stream", None)
+
# Use the adapter to convert to completion format
return GenerateContentToCompletionHandler.generate_content_handler(
model=model,