Skip to main content

Official Python SDK for the BESS AI Voice Platform

Project description

BESS AI Python SDK

Official Python SDK for the BESS AI Voice Platform.

Installation

pip install bessai

Quick Start

from bessai import BessAI

client = BessAI(api_key="bess_sk_live_a1b2c3d4...")

# Create an agent
agent = client.agents.create(
    name="Customer Support",
    llm_provider="openai",
    llm_model="gpt-4o",
    system_prompt="You are a helpful customer support agent.",
    voice_provider="elevenlabs",
    voice_id="21m00Tcm4TlvDq8ikWAM",
    language="en-US",
)

# Make a phone call
call = client.calls.create_phone_call(
    agent_id=agent.id,
    from_number="+14157774444",
    to_number="+12137774445",
    metadata={"customer_id": "cust_123"},
)

print(call.id)
print(call.status)

Async Usage

from bessai import AsyncBessAI

async def main():
    async with AsyncBessAI(api_key="bess_sk_live_...") as client:
        agents = await client.agents.list()
        for agent in agents:
            print(agent.name)

Configuration

# From environment variable
import os
os.environ["BESSAI_API_KEY"] = "bess_sk_live_..."
client = BessAI()  # Reads from BESSAI_API_KEY

# Custom base URL (self-hosted)
client = BessAI(
    api_key="bess_sk_live_...",
    base_url="https://your-instance.example.com",
    timeout=60.0,
    max_retries=5,
)

Resources

Resource Methods
client.agents create, list, get, update, delete, publish, list_versions
client.calls create_phone_call, create_web_call, list, get, end, delete
client.phone_numbers create, list, get, update, delete
client.batch_calls create, list, get, get_status, get_items, start, pause, resume, cancel, delete
client.workflows generate, list, get, update, delete, deploy, execute, test
client.analytics get_summary, get_latency, get_calls_by_day
client.knowledge_bases create, list, get, delete, upload_document, delete_document
client.api_keys create, list, get, update, delete, rotate, get_usage

Error Handling

from bessai import BessAI, AuthenticationError, RateLimitError, NotFoundError

client = BessAI(api_key="bess_sk_live_...")

try:
    agent = client.agents.get("invalid-id")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except NotFoundError:
    print("Agent not found")

API Key Management

# Create a scoped API key
key = client.api_keys.create(
    name="CI/CD Pipeline",
    scopes=["agents:read", "calls:write"],
    expires_in_days=90,
    rate_limit_tier="professional",
)
print(key.key)  # Only shown once!

# Rotate a key with 24h grace period
new_key = client.api_keys.rotate(key.id, grace_period_hours=24)

Requirements

  • Python >= 3.8
  • httpx >= 0.24.0
  • pydantic >= 2.0.0
  • websockets >= 11.0

License

MIT

Project details


Download files

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

Source Distribution

bessai-0.2.0.tar.gz (37.5 kB view details)

Uploaded Source

Built Distribution

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

bessai-0.2.0-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file bessai-0.2.0.tar.gz.

File metadata

  • Download URL: bessai-0.2.0.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bessai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2d20d7efc48da863ee89af25c9b6b439ed9324a693953887dc9b7916a14dad52
MD5 01f214145805982d17ff708f16351b3a
BLAKE2b-256 14dab23454638192f71e48a7d97c0276a97c8945c1d342c8a1baecda8f9da1ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for bessai-0.2.0.tar.gz:

Publisher: publish.yml on BESS-Analytics/bessai-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bessai-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bessai-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bessai-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6307831e6fe4e8cec5fd8e502102e02e975d7255080fa1ad7190b3e844cdcb8f
MD5 3020f5c5574a7ab18441095ae30fd97e
BLAKE2b-256 34aadf2ad3379af198c8ae560c5fb88e6662530a3e61bf3d6d7950e33e4881f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for bessai-0.2.0-py3-none-any.whl:

Publisher: publish.yml on BESS-Analytics/bessai-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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