From 00815a5ade0dee02354c9409a408bd77657d9cc9 Mon Sep 17 00:00:00 2001 From: KK Date: Tue, 31 Mar 2026 16:16:10 +0800 Subject: [PATCH] fix: do not pass base_url to ChatGoogleGenerativeAI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tradingagents/llm_clients/google_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tradingagents/llm_clients/google_client.py b/tradingagents/llm_clients/google_client.py index baa31add..48055560 100644 --- a/tradingagents/llm_clients/google_client.py +++ b/tradingagents/llm_clients/google_client.py @@ -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: