feat(providers): support provider-scoped proxy config

This commit is contained in:
chengyongru authored and Xubin Ren committed 2026-06-30 17:33:36 +08:00
1 parent 4c0e9b9f46
commit 44a5ed1bc0
15 files changed
+403 -24

No files matched your search

+10 -1
View File
@@ -358,6 +358,7 @@ class OpenAICompatProvider(LLMProvider):
extra_body: dict[str, Any] | None = None,
api_type: str = "auto",
extra_query: dict[str, str] | None = None,
proxy: str | None = None,
):
super().__init__(api_key, api_base)
self.default_model = default_model
@@ -366,6 +367,7 @@ class OpenAICompatProvider(LLMProvider):
self._extra_body = extra_body or {}
self._api_type = api_type if spec and spec.name == "openai" else "auto"
self._extra_query = extra_query or {}
self._proxy = proxy or None
if api_key and spec and spec.env_key:
self._setup_env(api_key, api_base)
@@ -396,7 +398,14 @@ class OpenAICompatProvider(LLMProvider):
timeout_s = _openai_compat_timeout_s()
http_client: httpx.AsyncClient | None = None
if self._is_local:
if self._proxy:
http_client = httpx.AsyncClient(
timeout=timeout_s,
proxy=self._proxy,
trust_env=False,
follow_redirects=True,
)
elif self._is_local:
# Local model servers (Ollama, llama.cpp, vLLM) often close idle
# HTTP connections before the client-side keepalive expires. When
# two LLM calls happen seconds apart (e.g. heartbeat _decide then