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
> **Note:** Pass the raw API key **without** the `"Bearer "` prefix — the client adds it automatically.
33
+
32
34
Now, you can use the client to interact with the Unstract API deployments API:
33
35
34
36
```python
@@ -61,10 +63,42 @@ except APIDeploymentsClientException as e:
61
63
62
64
## Parameter Details
63
65
66
+
`api_url`: The URL of the Unstract API deployment.
67
+
`api_key`: Your raw API key. **Do not** include the `"Bearer "` prefix — the client adds it automatically.
64
68
`api_timeout`: Set a timeout for API requests, e.g., `api_timeout=10`.
65
69
`logging_level`: Set logging verbosity (e.g., "`DEBUG`").
66
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.
67
71
72
+
## Retry Configuration
73
+
74
+
The client includes built-in exponential backoff retry with the following behavior:
75
+
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.
77
+
-**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
+
-**Status polling** (`check_execution_status`): GET requests are always retried, as they are idempotent.
79
+
80
+
Retries are enabled by default and can be customized:
81
+
82
+
```python
83
+
client = APIDeploymentsClient(
84
+
api_url="url",
85
+
api_key="your_api_key",
86
+
max_retries=4, # Max retry attempts (default: 4, set to 0 to disable)
87
+
initial_delay=2.0, # Initial delay in seconds (default: 2.0)
88
+
max_delay=60.0, # Maximum delay cap in seconds (default: 60.0)
89
+
backoff_factor=2.0, # Multiplier per retry (default: 2.0)
90
+
)
91
+
```
92
+
93
+
| Parameter | Default | Description |
94
+
|-----------|---------|-------------|
95
+
|`max_retries`|`4`| Maximum number of retry attempts. Set to `0` to disable retries. |
96
+
|`initial_delay`|`2.0`| Initial delay in seconds before the first retry. |
97
+
|`max_delay`|`60.0`| Maximum delay cap in seconds between retries. |
98
+
|`backoff_factor`|`2.0`| Multiplier applied to the delay for each subsequent retry. |
99
+
100
+
The retry logic uses exponential backoff with full jitter and respects the `Retry-After` header on 429 responses.
0 commit comments