Skip to main content

SignalWire SDK

Project description

SignalWire SDK for Python

Build AI voice agents, control live calls over WebSocket, and manage every SignalWire resource over REST -- all from one package.

Documentation · Report an Issue · PyPI

Discord MIT License GitHub Stars


What's in this SDK

Capability What it does Quick link
AI Agents Build voice agents that handle calls autonomously -- the platform runs the AI pipeline, your code defines the persona, tools, and call flow Agent Guide
RELAY Client Control live calls and SMS/MMS in real time over WebSocket -- answer, play, record, collect DTMF, conference, transfer, and more RELAY docs
REST Client Manage SignalWire resources over HTTP -- phone numbers, SIP endpoints, Fabric AI agents, video rooms, messaging, and 20 API namespaces REST docs
pip install signalwire-sdk

AI Agents

Each agent is a self-contained microservice that generates SWML (SignalWire Markup Language) and handles SWAIG (SignalWire AI Gateway) tool calls. The SignalWire platform runs the entire AI pipeline (STT, LLM, TTS) -- your agent just defines the behavior.

from signalwire import AgentBase
from signalwire.core.function_result import FunctionResult


class MyAgent(AgentBase):
    def __init__(self):
        super().__init__(name="my-agent", route="/agent")

        self.add_language(name="English", code="en-US", voice="inworld.Mark")
        self.prompt_add_section("Role", body="You are a helpful assistant.")

    @AgentBase.tool(name="get_time")
    def get_time(self):
        """Get the current time"""
        from datetime import datetime

        return FunctionResult(f"The time is {datetime.now().strftime('%H:%M:%S')}")


if __name__ == "__main__":
    agent = MyAgent()
    agent.run()

Test locally without running a server:

swaig-test my_agent.py --list-tools
swaig-test my_agent.py --dump-swml
swaig-test my_agent.py --exec get_time

Agent Features

  • Prompt Object Model (POM) -- structured prompt composition via prompt_add_section()
  • SWAIG tools -- define functions with @AgentBase.tool() that the AI calls mid-conversation, with native access to the call's media stack
  • Skills system -- add capabilities with one-liners: agent.add_skill("datetime")
  • Contexts and steps -- structured multi-step workflows with navigation control
  • DataMap tools -- tools that execute on SignalWire's servers, calling REST APIs without your own webhook
  • Dynamic configuration -- per-request agent customization for multi-tenant deployments
  • Call flow control -- pre-answer, post-answer, and post-AI verb insertion
  • Prefab agents -- ready-to-use archetypes (InfoGatherer, Survey, FAQ, Receptionist, Concierge)
  • Multi-agent hosting -- serve multiple agents on a single server with AgentServer
  • Local search -- offline document search with vector similarity and keyword matching
  • SIP routing -- route SIP calls to agents based on usernames
  • Session state -- persistent conversation state with global data and post-prompt summaries
  • Security -- auto-generated basic auth, function-specific HMAC tokens, SSL support
  • Serverless -- auto-detects Lambda, CGI, Google Cloud Functions, Azure Functions

Agent Examples

The examples/ directory contains 50+ working examples:

Example What it demonstrates
simple_agent.py POM prompts, SWAIG tools, multilingual support, LLM tuning
contexts_demo.py Multi-persona workflow with context switching and step navigation
data_map_demo.py Server-side API tools without webhooks
skills_demo.py Loading built-in skills (datetime, math)
call_flow_and_actions_demo.py Call flow verbs, debug events, FunctionResult actions
session_and_state_demo.py on_summary, global data, post-prompt summaries
multi_agent_server.py Multiple agents on one server
lambda_agent.py AWS Lambda deployment with Mangum
comprehensive_dynamic_agent.py Per-request dynamic configuration, multi-tenant routing

See examples/README.md for the full list organized by category.


RELAY Client

Real-time call control and messaging over WebSocket. The RELAY client connects to SignalWire via the Blade protocol and gives you imperative, async control over live phone calls and SMS/MMS.

from signalwire.relay import RelayClient

client = RelayClient(
    project="...", token="...", host="example.signalwire.com", contexts=["default"]
)


@client.on_call
async def handle(call):
    await call.answer()
    action = await call.play([{"type": "tts", "params": {"text": "Welcome!"}}])
    await action.wait()
    await call.hangup()


client.run()
  • 57+ calling methods (play, record, collect, detect, tap, stream, AI, conferencing, and more)
  • SMS/MMS messaging with delivery tracking
  • Action objects with wait(), stop(), pause(), resume()
  • Auto-reconnect with exponential backoff

See the RELAY documentation for the full guide, API reference, and examples.


REST Client

Synchronous REST client for managing SignalWire resources and controlling calls over HTTP. No WebSocket required.

from signalwire.rest import RestClient

client = RestClient(project="...", token="...", host="example.signalwire.com")

client.fabric.ai_agents.create(name="Support Bot", prompt={"text": "You are helpful."})
client.calling.play(call_id, play=[{"type": "tts", "params": {"text": "Hello!"}}])
client.phone_numbers.search(areacode="512")
client.datasphere.documents.search(query_string="billing policy")
  • 20 namespaced API surfaces: Fabric (13 resource types), Calling (37 commands), Video, Datasphere, Phone Numbers, SIP, Queues, Recordings, and more
  • Shared requests.Session for connection pooling
  • Dict returns -- raw JSON, no wrapper objects

See the REST documentation for the full guide, API reference, and examples.


Installation

# Core SDK (agents, RELAY, REST)
pip install signalwire-sdk

# With search (pick one based on your needs)
pip install signalwire-sdk[search-queryonly]   # Query pre-built .swsearch files (~400MB)
pip install signalwire-sdk[search]              # Build + query search indexes (~500MB)
pip install signalwire-sdk[search-full]         # + PDF, DOCX, Excel, HTML processing (~600MB)
pip install signalwire-sdk[search-all]          # All search features (~700MB)

Documentation

Full reference documentation is available at developer.signalwire.com/sdks/agents-sdk.

Guides are also available in the docs/ directory:

Getting Started

  • Agent Guide -- creating agents, prompt configuration, dynamic setup
  • Architecture -- SDK architecture and core concepts
  • SDK Features -- feature overview, SDK vs raw SWML comparison

Core Features

Skills and Extensions

Search System

Deployment

Reference

Tutorials

Environment Variables

Variable Used by Description
SIGNALWIRE_PROJECT_ID RELAY, REST Project identifier
SIGNALWIRE_API_TOKEN RELAY, REST API token
SIGNALWIRE_SPACE RELAY, REST Space hostname (e.g. example.signalwire.com)
SWML_BASIC_AUTH_USER Agents Basic auth username (default: auto-generated)
SWML_BASIC_AUTH_PASSWORD Agents Basic auth password (default: auto-generated)
SWML_PROXY_URL_BASE Agents Base URL when behind a reverse proxy
SWML_SSL_ENABLED Agents Enable HTTPS (true, 1, yes)
SWML_SSL_CERT_PATH Agents Path to SSL certificate
SWML_SSL_KEY_PATH Agents Path to SSL private key
SIGNALWIRE_LOG_LEVEL All Logging level (debug, info, warn, error)
SIGNALWIRE_LOG_MODE All Set to off to suppress all logging

Testing

# Install dev dependencies
pip install -r requirements-dev.txt

# Run the test suite
pytest

# Run by category
pytest -m unit
pytest -m integration
pytest -m skills

# Coverage
pytest --cov=signalwire --cov-report=html

License

MIT -- see LICENSE for details.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

signalwire_sdk-3.3.0.dev100.tar.gz (643.9 kB view details)

Uploaded Source

Built Distribution

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

signalwire_sdk-3.3.0.dev100-py3-none-any.whl (766.0 kB view details)

Uploaded Python 3

File details

Details for the file signalwire_sdk-3.3.0.dev100.tar.gz.

File metadata

  • Download URL: signalwire_sdk-3.3.0.dev100.tar.gz
  • Upload date:
  • Size: 643.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for signalwire_sdk-3.3.0.dev100.tar.gz
Algorithm Hash digest
SHA256 d877f5e9f6169c52de67e4ec43220e4c46b40398035eb565c4489d6b180aa32f
MD5 6145c356bd2fe5c183af50ef46bebff8
BLAKE2b-256 0bd0b2ac9de5519ea869151dec13a5e3102b1bbcd66ebb50beb5f4bd20d8ca97

See more details on using hashes here.

File details

Details for the file signalwire_sdk-3.3.0.dev100-py3-none-any.whl.

File metadata

File hashes

Hashes for signalwire_sdk-3.3.0.dev100-py3-none-any.whl
Algorithm Hash digest
SHA256 489443ae384cfaa0fa29a9d37e16d44b7bbaa7f6baa0b27bce8e5c299e606925
MD5 c087f1bc011688e5fc75e652cb7fa1d2
BLAKE2b-256 e3bf191c4ed699294f12d783e02dc5b376d0664044d13cbbb97314a7c652927a

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 Pingdom Monitoring Sentry Error logging StatusPage Status page