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
Copy file name to clipboardExpand all lines: README.md
+30-9Lines changed: 30 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,15 +65,28 @@ except APIDeploymentsClientException as e:
65
65
66
66
`api_url`: The URL of the Unstract API deployment.
67
67
`api_key`: Your raw API key. **Do not** include the `"Bearer "` prefix — the client adds it automatically.
68
-
`api_timeout`: Set a timeout for API requests, e.g., `api_timeout=10`.
68
+
`api_timeout`: Backend execution mode sent with the request (see `timeout` on `structure_file`). `0` or below queues the execution and returns immediately; above it the call runs synchronously and the value bounds how long the backend waits. This is not a socket timeout — pass `transport_timeout` for that.
69
69
`logging_level`: Set logging verbosity (e.g., "`DEBUG`").
70
70
`include_metadata`: If set to `True`, the response will include additional metadata (cost, tokens consumed and context) for each call made by the Prompt Studio exported tool.
71
+
`transport_timeout`: Socket timeout in seconds (keyword-only). Left unset, a stalled connection blocks forever, which is what earlier releases did.
72
+
73
+
## Closing the client
74
+
75
+
The client reuses connections between calls, so release them when you are done
76
+
with it — either by calling `close()`, or by using it as a context manager:
77
+
78
+
```python
79
+
with APIDeploymentsClient(api_url="url", api_key="your_api_key") as adc:
80
+
response = adc.structure_file(["<file>"])
81
+
```
82
+
83
+
A long-lived client can be left open; one built per job should be closed.
71
84
72
85
## Retry Configuration
73
86
74
87
The client includes built-in exponential backoff retry with the following behavior:
75
88
76
-
-**Async mode** (`api_timeout=0`): POST requests are retried on transient failures (5xx, 429) and connection errors, since the server returns immediately after queuing.
89
+
-**Async mode** (`api_timeout` of `0` or below): POST requests are retried on transient failures (5xx, 429) and connection errors, since the server returns immediately after queuing.
77
90
-**Sync mode** (`api_timeout > 0`, the default): POST requests are **not** retried, because the server blocks during processing — a failure may mean the request was processed but the response was lost.
78
91
-**Status polling** (`check_execution_status`): GET requests are always retried, as they are idempotent.
0 commit comments