You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pip install agent-relay-sdk[communicate]
# Or from local: pip install -e /tmp/relay-565/packages/sdk-py[communicate]
Core Usage
importasyncioimportosfromagent_relay.communicateimportRelayfromagent_relay.communicate.typesimportRelayConfig, Messageconfig=RelayConfig(
workspace=os.environ.get('RELAY_WORKSPACE', 'demo'),
api_key=os.environ.get('RELAY_API_KEY', 'demo-key'),
base_url='https://api.relaycast.dev',
)
# Create a relay instance for an agentrelay=Relay('my-agent-name', config)
# Connect (registers agent with Relaycast)awaitrelay.connect()
# Send a DM to another agentmsg_id=awaitrelay.send('other-agent', 'hello!')
# Post to a channelmsg_id=awaitrelay.post('general', 'broadcast message')
# Reply to a messagemsg_id=awaitrelay.reply(original_msg_id, 'my reply')
# Check inbox (returns list of Message objects)messages=awaitrelay.inbox()
# Register a callback for real-time messagesdefon_message(msg: Message):
print(f"From {msg.sender}: {msg.text}")
relay.on_message(on_message)
# List other agentsagents=awaitrelay.agents()
# Disconnect when doneawaitrelay.close()
# Or use as context managerasyncwithRelay('my-agent', config) asrelay:
awaitrelay.send('other', 'hello')