You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -162,29 +170,30 @@ if res.elements is not None:
162
170
163
171
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
164
172
```python
165
-
import unstructured_client
166
-
from unstructured_client.models importoperations, shared
173
+
from unstructured_clientimport UnstructuredClient
174
+
from unstructured_client.models import shared
167
175
from unstructured_client.utils import BackoffStrategy, RetryConfig
@@ -196,16 +205,81 @@ if res.elements is not None:
196
205
<!-- Start Custom HTTP Client [http-client] -->
197
206
## Custom HTTP Client
198
207
199
-
The Python SDK makes API calls using the [requests](https://pypi.org/project/requests/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object.
208
+
The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
209
+
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
210
+
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
200
211
201
212
For example, you could specify a header for every request that this sdk makes as follows:
202
213
```python
203
-
import unstructured_client
204
-
import requests
214
+
from unstructured_client import UnstructuredClient
s = UnstructuredClient(async_client=CustomClient(httpx.AsyncClient()))
209
283
```
210
284
<!-- End Custom HTTP Client [http-client] -->
211
285
@@ -216,6 +290,47 @@ s = unstructured_client.UnstructuredClient(client=http_client)
216
290
<!-- No Server Selection -->
217
291
<!-- No Authentication -->
218
292
293
+
<!-- Start File uploads [file-upload] -->
294
+
## File uploads
295
+
296
+
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
297
+
298
+
> [!TIP]
299
+
>
300
+
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
301
+
>
302
+
303
+
```python
304
+
from unstructured_client import UnstructuredClient
0 commit comments