Skip to main content

vapi_agent

A small, friendly Python wrapper around the Vapi voice-AI API. It ships both a synchronous and an asynchronous client, covers the full REST API through a uniform CRUD interface, and returns plain parsed JSON so you're never fighting the library.

from vapi_agent import VapiAgent

client = VapiAgent(api_key="your-private-key")
for assistant in client.assistants.list(limit=20):
    print(assistant["id"], assistant["name"])

Installation

pip install vapi-agent

Or, from a local checkout:

pip install -e .

Requires Python 3.8+ and depends only on httpx.

Authentication

Get your private API key from the Vapi dashboard. Pass it directly or set the VAPI_API_KEY environment variable:

client = VapiAgent(api_key="your-private-key")
# ...or, with VAPI_API_KEY set in the environment:
client = VapiAgent()

Use the private key server-side only. Never ship it in client-side code.

Resources

Every resource exposes the same five methods — list(), get(id), create(**fields), update(id, **fields), delete(id):

Attribute Vapi endpoint
client.assistants /assistant
client.calls /call
client.phone_numbers /phone-number
client.tools /tool
client.squads /squad
client.workflows /workflow
client.files /file
client.knowledge_bases /knowledge-base
client.test_suites /test-suite
client.analytics /analytics (.query(...))
client.logs /logs (read-only, .list(...))

Request bodies are passed as keyword arguments and forwarded as JSON, so you can use anything the Vapi API accepts without waiting for the library to add a field.

Examples

Create an assistant

assistant = client.assistants.create(
    name="Support Bot",
    model={
        "provider": "openai",
        "model": "gpt-4o",
        "messages": [{"role": "system", "content": "You are a helpful agent."}],
    },
    voice={"provider": "11labs", "voiceId": "burt"},
    firstMessage="Hi! How can I help you today?",
)
print(assistant["id"])

Make an outbound call

call = client.calls.create(
    assistantId=assistant["id"],
    phoneNumberId="your-phone-number-id",
    customer={"number": "+15551234567"},
)

Paginate with the timestamp filters

Vapi's list endpoints cap results with limit and page by createdAt rather than an offset:

def all_assistants(client, page_size=100):
    cursor = None
    while True:
        page = client.assistants.list(limit=page_size, createdAtLt=cursor)
        if not page:
            break
        yield from page
        cursor = page[-1]["createdAt"]
        if len(page) < page_size:
            break

Upload a file

file = client.files.create(path="./knowledge.pdf")

Async client

import asyncio
from vapi_agent import AsyncVapiAgent

async def main():
    async with AsyncVapiAgent(api_key="your-key") as client:
        assistants = await client.assistants.list(limit=20)
        print(len(assistants))

asyncio.run(main())

Analytics

result = client.analytics.query([
    {
        "name": "calls_by_day",
        "table": "call",
        "timeRange": {"step": "day"},
        "operations": [{"operation": "count", "column": "id"}],
    }
])

Error handling

Non-2xx responses raise a typed exception (all subclasses of VapiAPIError):

from vapi_agent import NotFoundError, AuthenticationError, VapiAPIError

try:
    client.assistants.get("does-not-exist")
except NotFoundError:
    print("no such assistant")
except AuthenticationError:
    print("check your API key")
except VapiAPIError as e:
    print(e.status_code, e.body)

Configuration

client = VapiAgent(
    api_key="your-key",
    base_url="https://api.vapi.ai",   # override for self-hosted/proxy
    timeout=60.0,
    default_headers={"X-My-Header": "value"},
)

Both clients support context managers (with / async with) and expose close() / aclose() for manual cleanup.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vapi_agent-0.1.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vapi_agent-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file vapi_agent-0.1.1.tar.gz.

File metadata

  • Download URL: vapi_agent-0.1.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for vapi_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 36b8f9d4cd50be4899db7dbfb80ca2095aa0959b53276ae66ba4b90530d0c778
MD5 6ae8b09b95e99d3f4c405e880e320fc8
BLAKE2b-256 fc5a5d407a29c7183edcda950d382774101e4a60adf83a245b25eaa74c7cd19a

See more details on using hashes here.

File details

Details for the file vapi_agent-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: vapi_agent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for vapi_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f35276693589971be55783f66280fdd33cd0bfaa9b0be8ef8f2d3860a1ab536
MD5 aec50ce6e6ea166d77c62bc7bf4d291d
BLAKE2b-256 43508a80219f07b12396159375bed75331a4cd434c198bd406da6a8317448b30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page