fix: do not pass base_url to ChatGoogleGenerativeAI

The CLI hardcodes backend_url as https://generativelanguage.googleapis.com/v1
for the Google provider and passes it as base_url to ChatGoogleGenerativeAI.
However, the google-genai SDK manages its own endpoint and API versioning
internally — passing an external base_url causes the SDK to construct
incorrect request paths, resulting in 404 Not Found errors for all Gemini
models including stable ones like gemini-2.5-flash.

Remove the base_url forwarding for Google clients so the SDK uses its
default endpoint logic.

Reproducer:
    ChatGoogleGenerativeAI(model="gemini-2.5-flash",
        base_url="https://generativelanguage.googleapis.com/v1").invoke("hi")
    # → ChatGoogleGenerativeAIError: 404 Not Found
This commit is contained in:
KK 2026-03-31 16:16:10 +08:00
parent 4641c03340
commit 00815a5ade
1 changed files with 4 additions and 2 deletions

View File

@ -28,8 +28,10 @@ class GoogleClient(BaseLLMClient):
self.warn_if_unknown_model()
llm_kwargs = {"model": self.model}
if self.base_url:
llm_kwargs["base_url"] = self.base_url
# base_url is intentionally NOT passed to ChatGoogleGenerativeAI.
# The google-genai SDK manages its own endpoint and API versioning internally.
# Passing a base_url (e.g. https://generativelanguage.googleapis.com/v1)
# causes 404s because the SDK appends its own paths onto the override URL.
for key in ("timeout", "max_retries", "callbacks", "http_client", "http_async_client"):
if key in self.kwargs: