Fix AsyncOpenAI proxy compatibility issue
- Create custom httpx.AsyncClient to avoid proxy argument error - This fixes 'AsyncClient.__init__() got an unexpected keyword argument proxies'
This commit is contained in:
parent
5ec2ef5911
commit
973bf5ab88
6
main.py
6
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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user