zrt.serve() runs your agent as a worker: it registers the agent under its agent_id with the Zero Runtime and serves a session to each caller. Fire zrt.invoke() from on_ready to launch a session and print a link you can open.
serve() blocks and keeps the worker running, accepting a fresh session for every caller until you stop it. Scale out by running more serve() workers, each registering the same agent_id.
Pass the
Agent subclass itself (Assistant, not Assistant()): serve(Assistant). serve() accepts the class only, never a pre-built instance, and builds a fresh agent and pipeline per call, which is required for correct per-call state and pipeline hooks under concurrent sessions.Start a session
serve() keeps your agent registered and idle. You then start a session to connect a caller to it. There are two ways, depending on where you’re calling from:
Both do the same thing: hand a session to a running worker registered under your
agent_id. Use whichever fits where you start the session.
Invoke with the SDK
During development, callzrt.invoke() from a script, a CLI, a web handler, or your agent’s on_ready hook. It returns the session details (session_id, room_id, worker_id), plus a playground_url when the room has playground=True (the default). Open it to talk to your agent right away.
Place a phone call
PassSip(...) to start the session on an outbound (or inbound) call instead of a playground room:
Dispatch with the API
In production, start a session over HTTP with the Dispatch API. It needs no SDK, works from any language or service, and supports both Agent Cloud and self-hosted agents, for both playground and SIP-connected sessions.meetingId and room_id (the SDK’s Room(room_id=...)) are the same identifier. The Dispatch API just calls it meetingId. Pass a room ID you already have, or omit it to auto-create one.Endpoint
Request body parameters
Example request
Responses
On success, the request returns a confirmation that the dispatch has been initiated:- No Workers Available
- No Workers Registered
- Agent Not Deployed
No servers and agents are configured to handle the request.
Inside the session
However you started it, once a session is live you control it from the agent’s hooks and tools. Reach it asself.session:
Connect your agent to the phone network
With your agent running locally, connect it to the outside world by setting up gateways and routing rules in your Zero Runtime Dashboard or via the Zero Runtime API.- Via Dashboard
- Via API
1
Add SIP Configuration
- Go to the Zero Runtime Dashboard.
- Click on Add Number.
- Click on Configure SIP.
- Give a name and add your phone number.
2
Setup Inbound Gateway
- Copy the Inbound URL from the Zero Runtime Dashboard.
- Go to Twilio and create a new SIP Trunk.
- Go to the Origination section, paste the Inbound URL there, and save it.
3
Setup Outbound Gateway
- Go to the Termination section in Twilio, create a URI, and paste it into the outbound section in the Zero Runtime Dashboard.
- Create a username and password in Twilio and add it to the Zero Runtime outbound section.
4
Setup Routing Rules
- Click on Configure rule then Create new routing rule.
- Add Routing Rule Name.
- Select API Key.
- Add Call Direction (Inbound or Outbound).
- Add Phone Number.
- Add Room Type.
- Add Agent ID.
- Click Save.
Make and receive calls
Your setup is complete. Test it out.Making an inbound call
- Using any phone, dial the SIP number you configured.
- Your local agent will automatically answer.
- You’ll hear the greeting: “Hello! I’m your real-time assistant. How can I help you today?”
- Start talking. The agent will listen and respond in real time.
Making an outbound call
Trigger an outbound call from your agent with a simple API request. Usecurl or any API client to make a POST request to the Zero Runtime API. Replace $YOUR_TOKEN and the routingRuleId with your own.
What’s Next
Create an Agent
Define the agent that serve runs.
Tools and Capabilities
Give the agent function tools and external services.
Telephony
DTMF, call transfer, and voicemail detection.
Deploy an Agent
Take your agent to production.