Skip to content

Commit cd194df

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix(client): handle domains with underscores (#1726)
1 parent 30f84b9 commit cd194df

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/openai/_base_client.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,17 @@ def _build_request(
490490
if not files:
491491
files = cast(HttpxRequestFiles, ForceMultipartDict())
492492

493+
prepared_url = self._prepare_url(options.url)
494+
if "_" in prepared_url.host:
495+
# work around https://github.com/encode/httpx/discussions/2880
496+
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
497+
493498
# TODO: report this error to httpx
494499
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
495500
headers=headers,
496501
timeout=self.timeout if isinstance(options.timeout, NotGiven) else options.timeout,
497502
method=options.method,
498-
url=self._prepare_url(options.url),
503+
url=prepared_url,
499504
# the `Query` type that we use is incompatible with qs'
500505
# `Params` type as it needs to be typed as `Mapping[str, object]`
501506
# so that passing a `TypedDict` doesn't cause an error.

0 commit comments

Comments
 (0)