For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • BedrockAgent
      • CLI Tools
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
      • SWMLBuilder
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
        • connect
        • dial
        • disconnect
        • execute
        • receive
        • run
        • send_message
        • unreceive
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
RELAYRelayClient

run

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

send_message

Next
Built with

Blocking entry point that connects to RELAY and runs the event loop until interrupted. This is the recommended way to start a RelayClient for long-running services. It calls connect() internally and automatically reconnects with exponential backoff (1 second initial delay, up to 30 seconds maximum) if the connection is lost.

The method blocks the current thread. Press Ctrl+C to trigger a clean shutdown — the client handles SIGINT gracefully without dumping a stack trace.

run() is synchronous and creates its own asyncio event loop via asyncio.run(). Do not call it from inside an already-running async event loop. For async contexts, use connect() and disconnect() directly.

Parameters

None.

Returns

None — blocks until the client is stopped via Ctrl+C or a programmatic shutdown.

Example

1from signalwire.relay import RelayClient
2
3client = RelayClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7 contexts=["default"],
8)
9
10@client.on_call
11async def handle_call(call):
12 await call.answer()
13 action = await call.play([{"type": "tts", "text": "Welcome! Goodbye."}])
14 await action.wait()
15 await call.hangup()
16
17# Blocks forever, reconnects on connection loss
18client.run()