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
{{ message }}
Repository navigation
Commit 01ebf69
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+62-69Lines changed: 62 additions & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,138 +7,131 @@ The Vapi Python library provides convenient access to the Vapi API from Python.
7
7
8
8
## Installation
9
9
10
-
```sh
11
-
pip install vapi_server_sdk
10
+
This release supports Python 3.10 through 3.14.
11
+
12
+
```bash
13
+
python -m pip install vapi_server_sdk
14
+
```
15
+
16
+
Install the optional async transport:
17
+
18
+
```bash
19
+
python -m pip install "vapi_server_sdk[aiohttp]"
20
+
```
21
+
22
+
## Upgrade to 3.0.0
23
+
24
+
Version 3.0.0 updates the generated types to the current Vapi API definition. Review the [3.0.0 migration notes](./changelog.md) before upgrading from 1.x. Public helper imports, declared model fields, and structured-output run response types have changed.
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
55
-
will be thrown.
72
+
Catch `ApiError` to inspect an unsuccessful API response:
56
73
57
74
```python
75
+
import os
76
+
77
+
from vapi import Vapi
58
78
from vapi.core.api_error import ApiError
59
79
80
+
client = Vapi(token=os.environ["VAPI_API_KEY"])
60
81
try:
61
-
client.calls.create(...)
62
-
except ApiError ase:
63
-
print(e.status_code)
64
-
print(e.body)
82
+
client.assistants.list(limit=10)
83
+
except ApiError aserror:
84
+
print(error.status_code)
85
+
print(error.body)
65
86
```
66
87
67
-
## Pagination
88
+
## List Resources
68
89
69
-
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.
70
-
71
-
```python
72
-
from vapi import Vapi
73
-
74
-
client = Vapi(
75
-
token="YOUR_TOKEN",
76
-
)
77
-
response = client.logs.get()
78
-
for item in response:
79
-
yield item
80
-
# alternatively, you can paginate page-by-page
81
-
for page in response.iter_pages():
82
-
yield page
83
-
```
90
+
`client.assistants.list()` returns a Python list. Use its `limit` and timestamp filters to select results. Other endpoints have their own response types and pagination parameters; consult the [SDK reference](./reference.md) for the endpoint you use.
84
91
85
92
## Advanced
86
93
87
94
### Retries
88
95
89
-
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
90
-
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
91
-
retry limit (default: 2).
92
-
93
-
A request is deemed retriable when any of the following HTTP status codes is returned:
96
+
The SDK retries HTTP 408, 409, 429, and 5xx responses with backoff. The default maximum is two retries. Set `max_retries` for an individual request:
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
109
+
The default client timeout is 60 seconds. Set `timeout` when creating the client or override it with `timeout_in_seconds` for a request. When you supply a custom HTTPX client, its read timeout becomes the default unless you set `timeout` explicitly.
0 commit comments