Skip to content
Integrations/Official SDKs
Python Logo

Python SDK

The official Python SDK for the Vobiz Voice API. Make outbound calls, manage SIP trunks, handle phone numbers, and build dynamic call flows using VobizXML—all seamlessly integrated into your Python applications.

Source Code & API Reference: vobiz-ai/Vobiz-Python-SDK

Installation

Clone the repository and install the dependencies locally:

Bash
git clone https://github.com/vobiz-ai/Vobiz-Python-SDK.git
cd Vobiz-Python-SDK
pip install -e .

Authentication

Vobiz uses your Auth ID and Auth Token. Both can be found within the Vobiz Console.

We heavily recommend exposing these as environment variables:

Bash
export VOBIZ_AUTH_ID=YOUR_AUTH_ID\nexport VOBIZ_AUTH_TOKEN=YOUR_AUTH_TOKEN
Python
import vobiz

# Reads VOBIZ_AUTH_ID and VOBIZ_AUTH_TOKEN from your environment
client = vobiz.RestClient()

Or passed explicitly:

Python
client = vobiz.RestClient(auth_id="MA_XXXXXXXXXX", auth_token="your_token")

Quick Start (Outbound Calls)

Creating an outbound call requires passing your origin number, destination number, and your webhook URLs. When the destination party answers the phone, Vobiz will instantly make a synchronous HTTP request to your answer_url to ask for instructions on what to do next.

Python
import vobiz

client = vobiz.RestClient()

response = client.calls.create(
    from_="+911234567890",          # Your Vobiz DID number
    to_="+919876543210",            # Destination number
    answer_url="https://your-server.com/answer",  # Server returning VobizXML
    answer_method="GET",
)

print("Call UUID:", response.request_uuid)

Receiving Calls (Flask Server)

Below is a rapid implementation of a webhook answer server using Flask. When an outbound call connects (or an inbound call arrives), Vobiz requests your answer_url to interpret the VobizXML instructions.

Python
from flask import Flask, request, Response
from vobiz import vobizxml

app = Flask(__name__)

@app.route('/answer', methods=['GET', 'POST'])
def answer():
    # Capture incoming REST details
    call_uuid  = request.values.get('CallUUID')
    from_num   = request.values.get('From')
    to_num     = request.values.get('To')

    print(f"Incoming call {call_uuid}: {from_num} → {to_num}")

    # Utilize SDK VobizXML abstractions natively
    response = vobizxml.ResponseElement()
    response.add_speak(
        "Hello! You have reached our Python application.",
        voice="WOMAN",
        language="en-US",
    )
    response.add_hangup()

    return Response(response.to_string(), status=200, mimetype='application/xml')

if __name__ == '__main__':
    app.run(port=5001)

VobizXML Module

The Python SDK exposes a tightly integrated vobizxml module allowing you to construct robust IVR systems safely without manually formatting stringified XML blocks. This is extremely useful for building complex, nested voice menus (like pressing 1 for Sales, or collecting speech input via AI models). It automatically handles escaping and schema validations.

Python
from vobiz import vobizxml

response = vobizxml.ResponseElement()

# Collect Speech + DTMF
gather = response.add_gather(
    action="https://your-server.com/gather-result",
    input_type="dtmf speech",
    execution_timeout=15,
)
gather.add_speak("Welcome to Acme Corp. Press 1 or say Sales.")
gather.add_play("https://your-server.com/audio/menu.mp3")

xml_string = response.to_string(pretty=True)
print(xml_string)

Core Resources

The Python SDK maps strictly to the REST API submodules. Below are quick examples of navigating other common resource pools natively without explicitly curling URLs via requests.

Phone Numbers & Account Capacity

Python
# Purchase a new number out of the public inventory seamlessly
client.phone_numbers.purchase_from_inventory(e164="+911234567890", currency="INR")

# Fetch your account live balance without dashboards
balance = client.accounts.get_balance(auth_id="YOUR_AUTH_ID", currency="INR")
print(balance.available_balance, balance.currency)

Call Tracking & CDR Logs

Python
# List historical paginated Call Detail Records natively returning objects
cdrs = client.cdrs.list(start_date="2026-01-01", end_date="2026-01-31", page=1, per_page=20)
for cdr in cdrs.data:
    print(cdr['call_id'], cdr['duration'], cdr['status'])