Skip to content

Commit c6ba15a

Browse files
committed
Release 0.0.0
1 parent 18146a6 commit c6ba15a

File tree

581 files changed

+51957
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

581 files changed

+51957
-2
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Specify files that shouldn't be modified by Fern

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: ci
2+
3+
on: [push]
4+
jobs:
5+
compile:
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- name: Checkout repo
9+
uses: actions/checkout@v3
10+
- name: Set up python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: 3.8
14+
- name: Bootstrap poetry
15+
run: |
16+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
17+
- name: Install dependencies
18+
run: poetry install
19+
- name: Compile
20+
run: poetry run mypy .
21+
test:
22+
runs-on: ubuntu-20.04
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@v3
26+
- name: Set up python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: 3.8
30+
- name: Bootstrap poetry
31+
run: |
32+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
33+
- name: Install dependencies
34+
run: poetry install
35+
36+
- name: Test
37+
run: poetry run pytest -rP .
38+
39+
publish:
40+
needs: [compile, test]
41+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
42+
runs-on: ubuntu-20.04
43+
steps:
44+
- name: Checkout repo
45+
uses: actions/checkout@v3
46+
- name: Set up python
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: 3.8
50+
- name: Bootstrap poetry
51+
run: |
52+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
53+
- name: Install dependencies
54+
run: poetry install
55+
- name: Publish to pypi
56+
run: |
57+
poetry config repositories.remote https://upload.pypi.org/legacy/
58+
poetry --no-interaction -v publish --build --repository remote --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD"
59+
env:
60+
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
61+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist/
2+
.mypy_cache/
3+
__pycache__/
4+
poetry.toml
5+
.ruff_cache/

README.md

Lines changed: 130 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,130 @@
1-
# vapi-python-sdk
2-
The official Python SDK for accessing Vapi's API
1+
# Vapi Python Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)
4+
[![pypi](https://img.shields.io/pypi/v/Vapi)](https://pypi.python.org/pypi/Vapi)
5+
6+
The Vapi Python library provides convenient access to the Vapi API from Python.
7+
8+
## Installation
9+
10+
```sh
11+
pip install Vapi
12+
```
13+
14+
## Usage
15+
16+
Instantiate and use the client with the following:
17+
18+
```python
19+
from vapi import Vapi
20+
21+
client = Vapi(
22+
token="YOUR_TOKEN",
23+
)
24+
client.calls.create()
25+
```
26+
27+
## Async Client
28+
29+
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
30+
31+
```python
32+
import asyncio
33+
34+
from vapi import AsyncVapi
35+
36+
client = AsyncVapi(
37+
token="YOUR_TOKEN",
38+
)
39+
40+
41+
async def main() -> None:
42+
await client.calls.create()
43+
44+
45+
asyncio.run(main())
46+
```
47+
48+
## Exception Handling
49+
50+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
51+
will be thrown.
52+
53+
```python
54+
from vapi.core.api_error import ApiError
55+
56+
try:
57+
client.calls.create(...)
58+
except ApiError as e:
59+
print(e.status_code)
60+
print(e.body)
61+
```
62+
63+
## Advanced
64+
65+
### Retries
66+
67+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
68+
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
69+
retry limit (default: 2).
70+
71+
A request is deemed retriable when any of the following HTTP status codes is returned:
72+
73+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
74+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
75+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
76+
77+
Use the `max_retries` request option to configure this behavior.
78+
79+
```python
80+
client.calls.create(..., {
81+
"max_retries": 1
82+
})
83+
```
84+
85+
### Timeouts
86+
87+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
88+
89+
```python
90+
91+
from vapi import Vapi
92+
93+
client = Vapi(
94+
...,
95+
timeout=20.0,
96+
)
97+
98+
99+
# Override timeout for a specific method
100+
client.calls.create(..., {
101+
"timeout_in_seconds": 1
102+
})
103+
```
104+
105+
### Custom Client
106+
107+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
108+
and transports.
109+
```python
110+
import httpx
111+
from vapi import Vapi
112+
113+
client = Vapi(
114+
...,
115+
httpx_client=httpx.Client(
116+
proxies="http://my.test.proxy.example.com",
117+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
118+
),
119+
)
120+
```
121+
122+
## Contributing
123+
124+
While we value open-source contributions to this SDK, this library is generated programmatically.
125+
Additions made directly to this library would have to be moved over to our generation code,
126+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
127+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
128+
an issue first to discuss with us!
129+
130+
On the other hand, contributions to the README are always very welcome!

0 commit comments

Comments
 (0)