fix: disable SSL verification for OpenAI proxy with self-signed cert

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-24 08:59:06 -08:00
parent d43baed3a5
commit f8f0d17820
1 changed files with 3 additions and 0 deletions

View File

@ -284,6 +284,7 @@ async def stt_transcribe(request: Request, audio: UploadFile = File(...)):
def _get_openai_client(): def _get_openai_client():
"""Lazy-init OpenAI client with proxy support.""" """Lazy-init OpenAI client with proxy support."""
from openai import OpenAI from openai import OpenAI
import httpx
api_key = os.environ.get("OPENAI_API_KEY") api_key = os.environ.get("OPENAI_API_KEY")
base_url = os.environ.get("OPENAI_BASE_URL") base_url = os.environ.get("OPENAI_BASE_URL")
if not api_key: if not api_key:
@ -291,6 +292,8 @@ def _get_openai_client():
kwargs = {"api_key": api_key} kwargs = {"api_key": api_key}
if base_url: if base_url:
kwargs["base_url"] = base_url kwargs["base_url"] = base_url
# Disable SSL verification for self-signed proxy certs
kwargs["http_client"] = httpx.Client(verify=False)
return OpenAI(**kwargs) return OpenAI(**kwargs)