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)

        # Stream batch call status
        async with client.streaming.batch_call_status("campaign-id") as stream:
            async for event in stream:
                print(event)

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.1.0.tar.gz (32.9 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.1.0-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bessai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c6f8f65f56e7e72a56d7ad0727c7e6faac438ce9c5fc79ac79d3778a7fb9426
MD5 f1d0b7748b057e52635a0093645f7e4f
BLAKE2b-256 84b125db5e8b4c7deefe0b4c64831ca5f833cd311711392e7163f989987c85e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for bessai-0.1.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.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for bessai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 546855dbe944ff749efe64f398e2df215415e2324a6ebe933e667d578a019c3c
MD5 1a3f1d1672148d4e87d70d21046e8be4
BLAKE2b-256 b110991e5f19a7cd8d1a6a0f10565beb3bd38df0aefa38512dd775c125f50d3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bessai-0.1.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