Skip to content

Commit 33b12c9

Browse files
committed
fix: make verify a client parameter (openai#1204)
Signed-off-by: Teodor-Dumitru Ene <[email protected]>
1 parent e41abf7 commit 33b12c9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/openai/_base_client.py

+9
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
328328
_base_url: URL
329329
max_retries: int
330330
timeout: Union[float, Timeout, None]
331+
verify: httpx._types.VerifyTypes = True
331332
_limits: httpx.Limits
332333
_proxies: ProxiesTypes | None
333334
_transport: Transport | AsyncTransport | None
@@ -343,6 +344,7 @@ def __init__(
343344
_strict_response_validation: bool,
344345
max_retries: int = DEFAULT_MAX_RETRIES,
345346
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
347+
verify: httpx._types.VerifyTypes = True,
346348
limits: httpx.Limits,
347349
transport: Transport | AsyncTransport | None,
348350
proxies: ProxiesTypes | None,
@@ -353,6 +355,7 @@ def __init__(
353355
self._base_url = self._enforce_trailing_slash(URL(base_url))
354356
self.max_retries = max_retries
355357
self.timeout = timeout
358+
self.verify = verify
356359
self._limits = limits
357360
self._proxies = proxies
358361
self._transport = transport
@@ -727,6 +730,7 @@ def __init__(
727730
base_url: str | URL,
728731
max_retries: int = DEFAULT_MAX_RETRIES,
729732
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
733+
verify: httpx._types.VerifyTypes = True,
730734
transport: Transport | None = None,
731735
proxies: ProxiesTypes | None = None,
732736
limits: Limits | None = None,
@@ -786,6 +790,7 @@ def __init__(
786790
base_url=base_url,
787791
transport=transport,
788792
max_retries=max_retries,
793+
verify=verify,
789794
custom_query=custom_query,
790795
custom_headers=custom_headers,
791796
_strict_response_validation=_strict_response_validation,
@@ -794,6 +799,7 @@ def __init__(
794799
base_url=base_url,
795800
# cast to a valid type because mypy doesn't understand our type narrowing
796801
timeout=cast(Timeout, timeout),
802+
verify=verify,
797803
proxies=proxies,
798804
transport=transport,
799805
limits=limits,
@@ -1270,6 +1276,7 @@ def __init__(
12701276
_strict_response_validation: bool,
12711277
max_retries: int = DEFAULT_MAX_RETRIES,
12721278
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1279+
verify: httpx._types.VerifyTypes = True,
12731280
transport: AsyncTransport | None = None,
12741281
proxies: ProxiesTypes | None = None,
12751282
limits: Limits | None = None,
@@ -1328,6 +1335,7 @@ def __init__(
13281335
proxies=proxies,
13291336
transport=transport,
13301337
max_retries=max_retries,
1338+
verify=verify,
13311339
custom_query=custom_query,
13321340
custom_headers=custom_headers,
13331341
_strict_response_validation=_strict_response_validation,
@@ -1336,6 +1344,7 @@ def __init__(
13361344
base_url=base_url,
13371345
# cast to a valid type because mypy doesn't understand our type narrowing
13381346
timeout=cast(Timeout, timeout),
1347+
verify=verify,
13391348
proxies=proxies,
13401349
transport=transport,
13411350
limits=limits,

src/openai/_client.py

+8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(
7272
base_url: str | httpx.URL | None = None,
7373
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
7474
max_retries: int = DEFAULT_MAX_RETRIES,
75+
verify: httpx._types.VerifyTypes = True,
7576
default_headers: Mapping[str, str] | None = None,
7677
default_query: Mapping[str, object] | None = None,
7778
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
@@ -114,6 +115,7 @@ def __init__(
114115
base_url=base_url,
115116
max_retries=max_retries,
116117
timeout=timeout,
118+
verify=verify,
117119
http_client=http_client,
118120
custom_headers=default_headers,
119121
custom_query=default_query,
@@ -165,6 +167,7 @@ def copy(
165167
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
166168
http_client: httpx.Client | None = None,
167169
max_retries: int | NotGiven = NOT_GIVEN,
170+
verify: httpx._types.VerifyTypes = None,
168171
default_headers: Mapping[str, str] | None = None,
169172
set_default_headers: Mapping[str, str] | None = None,
170173
default_query: Mapping[str, object] | None = None,
@@ -200,6 +203,7 @@ def copy(
200203
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
201204
http_client=http_client,
202205
max_retries=max_retries if is_given(max_retries) else self.max_retries,
206+
verify=verify or self.verify,
203207
default_headers=headers,
204208
default_query=params,
205209
**_extra_kwargs,
@@ -270,6 +274,7 @@ def __init__(
270274
base_url: str | httpx.URL | None = None,
271275
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
272276
max_retries: int = DEFAULT_MAX_RETRIES,
277+
verify: httpx._types.VerifyTypes = True,
273278
default_headers: Mapping[str, str] | None = None,
274279
default_query: Mapping[str, object] | None = None,
275280
# Configure a custom httpx client. See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
@@ -312,6 +317,7 @@ def __init__(
312317
base_url=base_url,
313318
max_retries=max_retries,
314319
timeout=timeout,
320+
verify=verify,
315321
http_client=http_client,
316322
custom_headers=default_headers,
317323
custom_query=default_query,
@@ -363,6 +369,7 @@ def copy(
363369
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
364370
http_client: httpx.AsyncClient | None = None,
365371
max_retries: int | NotGiven = NOT_GIVEN,
372+
verify: httpx._types.VerifyTypes = None,
366373
default_headers: Mapping[str, str] | None = None,
367374
set_default_headers: Mapping[str, str] | None = None,
368375
default_query: Mapping[str, object] | None = None,
@@ -398,6 +405,7 @@ def copy(
398405
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
399406
http_client=http_client,
400407
max_retries=max_retries if is_given(max_retries) else self.max_retries,
408+
verify=verify or self.verify,
401409
default_headers=headers,
402410
default_query=params,
403411
**_extra_kwargs,

0 commit comments

Comments
 (0)