@@ -716,7 +716,27 @@ def _idempotency_key(self) -> str:
716
716
return f"stainless-python-retry-{ uuid .uuid4 ()} "
717
717
718
718
719
- class SyncHttpxClientWrapper (httpx .Client ):
719
+ class _DefaultHttpxClient (httpx .Client ):
720
+ def __init__ (self , ** kwargs : Any ) -> None :
721
+ kwargs .setdefault ("timeout" , DEFAULT_TIMEOUT )
722
+ kwargs .setdefault ("limits" , DEFAULT_CONNECTION_LIMITS )
723
+ kwargs .setdefault ("follow_redirects" , True )
724
+ super ().__init__ (** kwargs )
725
+
726
+
727
+ if TYPE_CHECKING :
728
+ DefaultHttpxClient = httpx .Client
729
+ """An alias to `httpx.Client` that provides the same defaults that this SDK
730
+ uses internally.
731
+
732
+ This is useful because overriding the `http_client` with your own instance of
733
+ `httpx.Client` will result in httpx's defaults being used, not ours.
734
+ """
735
+ else :
736
+ DefaultHttpxClient = _DefaultHttpxClient
737
+
738
+
739
+ class SyncHttpxClientWrapper (DefaultHttpxClient ):
720
740
def __del__ (self ) -> None :
721
741
try :
722
742
self .close ()
@@ -1262,7 +1282,27 @@ def get_api_list(
1262
1282
return self ._request_api_list (model , page , opts )
1263
1283
1264
1284
1265
- class AsyncHttpxClientWrapper (httpx .AsyncClient ):
1285
+ class _DefaultAsyncHttpxClient (httpx .AsyncClient ):
1286
+ def __init__ (self , ** kwargs : Any ) -> None :
1287
+ kwargs .setdefault ("timeout" , DEFAULT_TIMEOUT )
1288
+ kwargs .setdefault ("limits" , DEFAULT_CONNECTION_LIMITS )
1289
+ kwargs .setdefault ("follow_redirects" , True )
1290
+ super ().__init__ (** kwargs )
1291
+
1292
+
1293
+ if TYPE_CHECKING :
1294
+ DefaultAsyncHttpxClient = httpx .AsyncClient
1295
+ """An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
1296
+ uses internally.
1297
+
1298
+ This is useful because overriding the `http_client` with your own instance of
1299
+ `httpx.AsyncClient` will result in httpx's defaults being used, not ours.
1300
+ """
1301
+ else :
1302
+ DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
1303
+
1304
+
1305
+ class AsyncHttpxClientWrapper (DefaultAsyncHttpxClient ):
1266
1306
def __del__ (self ) -> None :
1267
1307
try :
1268
1308
# TODO(someday): support non asyncio runtimes here
0 commit comments