Skip to content

Commit 0e9fc3d

Browse files
committed
fix(cli): remove usage of httpx proxies
1 parent 534d6c5 commit 0e9fc3d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/openai/cli/_cli.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from .. import _ApiType, __version__
1616
from ._api import register_commands
1717
from ._utils import can_use_http2
18-
from .._types import ProxiesDict
1918
from ._errors import CLIError, display_error
2019
from .._compat import PYDANTIC_V2, ConfigDict, model_parse
2120
from .._models import BaseModel
@@ -167,17 +166,17 @@ def _main() -> None:
167166
if args.verbosity != 0:
168167
sys.stderr.write("Warning: --verbosity isn't supported yet\n")
169168

170-
proxies: ProxiesDict = {}
169+
proxies: dict[str, httpx.BaseTransport] = {}
171170
if args.proxy is not None:
172171
for proxy in args.proxy:
173172
key = "https://" if proxy.startswith("https") else "http://"
174173
if key in proxies:
175174
raise CLIError(f"Multiple {key} proxies given - only the last one would be used")
176175

177-
proxies[key] = proxy
176+
proxies[key] = httpx.HTTPTransport(proxy=httpx.Proxy(httpx.URL(proxy)))
178177

179178
http_client = httpx.Client(
180-
proxies=proxies or None,
179+
mounts=proxies or None,
181180
http2=can_use_http2(),
182181
)
183182
openai.http_client = http_client

0 commit comments

Comments
 (0)