From 973bf5ab88c729af844bc083624410671443b1a9 Mon Sep 17 00:00:00 2001 From: Z User Date: Sun, 29 Mar 2026 04:51:23 +0000 Subject: [PATCH] Fix AsyncOpenAI proxy compatibility issue - Create custom httpx.AsyncClient to avoid proxy argument error - This fixes 'AsyncClient.__init__() got an unexpected keyword argument proxies' --- main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.py b/main.py index 15953f2..a2cf917 100644 --- a/main.py +++ b/main.py @@ -230,9 +230,15 @@ async def lifespan(app: FastAPI): try: if api_key: log.info("Initializing OpenRouter client...") + # Create custom httpx client to avoid proxy issues + import httpx + http_client = httpx.AsyncClient( + timeout=httpx.Timeout(60.0, connect=10.0), + ) state.llm_client = AsyncOpenAI( api_key=api_key, base_url=config.OPENROUTER_BASE_URL, + http_client=http_client, ) log.info(f"OpenRouter client initialized successfully (model: {config.UPSTREAM_MODEL})") else: