Every modality ships with a runnable example in the python-sdk repo.

Voice — outbound call, agent attach

from clutchcall.voice import Voice

v    = Voice(base_url=BASE_URL, api_key=KEY, org_id=ORG)
call = v.calls.originate(
    to="+15551234567", from_="+15558675309",
    trunk_id="trunk_main", agent="healthcare-assistant",
)
bridge = v.audio_bridge.attach(call.sid, codec="opus",
                               on_uplink=lambda f, ts: my_asr.feed(f))
examples/voice_originate.py

Streams — record a broadcast

from clutchcall.streams import Streams, BroadcastViewer

streams = Streams(base_url=BASE_URL, api_key=KEY, org_id=ORG)
signed  = streams.live_inputs.get(id="li_xyz") \
                             .signed_playback_url(ttl_seconds=7200)

with open(f"recordings/clutchcall-li_xyz.mp4", "wb") as f:
    BroadcastViewer.open(signed["url"],
                         on_chunk=lambda init, chunk: f.write(chunk))
examples/streams_publish.py · examples/streams_record.py

Robotics — bridge ROS 2 odometry to the relay

from clutchcall.robotics import Robotics, QoSProfile

r    = Robotics(relay_host="relay.clutchcall.dev", token=TOKEN, robot_id="tb-7")
odom = r.publish_telemetry(
    topic="odom", type_name="nav_msgs/msg/Odometry",
    qos=QoSProfile(reliability="reliable", depth=10),
)

def on_ros_odom(ros_msg):
    odom.write(serialize_cdr(ros_msg))
examples/robotics_publish.py

Games — authoritative server tick loop

import time
from clutchcall.games import Games

auth  = Games(relay_host="relay.clutchcall.dev", token=TOKEN, room_id="duel-42")
state = auth.publish_state(tick_hz=30)

auth.subscribe_inputs(on_input=lambda pid, p: world.apply(pid, p))

while True:
    state.write(world.snapshot())
    time.sleep(1 / 30)

Data — device-side temperature publisher

import time
from clutchcall.data import Data

d = Data(relay_host="relay.clutchcall.dev", token=TOKEN, client_id="device-7")

while True:
    d.publish(topic="sensors/room1/temperature",
              payload=f"{read_sensor():.2f}".encode())
    time.sleep(5)