zeroruntime.serve() runs your agent as a worker: it registers the agent with Zero Runtime
and waits. Each time you start a session, the worker serves it with a fresh instance of your
agent. How you start one depends on where you are:
- Local development: call
zeroruntime.invoke()from your code, or runzeroruntime invokefrom the CLI. Both open a playground link you can talk to. - Production: deploy your worker to Zero Runtime Cloud
or self-host it. Sessions then start from phone calls: inbound calls reach your agent through a
routing rule, and you place outbound calls with the
/v2/sip/callAPI.
Run it locally
During development, start the worker and firezeroruntime.invoke() from on_ready. As soon
as the worker registers, it opens a playground session and prints a link you can open to talk
to your agent.
serve() blocks and keeps the worker running, accepting a fresh session for every caller until
you stop it. Code after serve() never runs, so use on_ready for anything that should happen
once the worker is up. To scale out, run more workers with the same agent ID; the runtime
load-balances sessions across them.
Go to production
on_ready + invoke() is only for local testing. Remove it before you deploy, or every worker
you start dispatches the agent into a new room on startup. In production, sessions come from the
zeroruntime invoke CLI, or
phone calls.
Zero Runtime Cloud
One command deploys your agent. Zero Runtime builds, hosts, and scales it for you.
Self-Hosting
Run the worker on your own Docker host, VM, or Kubernetes cluster.
Connect to the phone network
Connecting your agent to the phone network takes three steps:- Add a phone number: import one you own, or bring your own SIP trunk.
- Create a routing rule: link the number to your agent.
- Place a call: call the agent, or have it call out.
1. Add a phone number
- Import number
- Bring your own SIP (BYOS)
Import a number you already own from a supported provider (Twilio or Plivo). The video uses Twilio.
1
Open Telephony
In the Zero Runtime Dashboard, open Telephony and select Add Number → Import Number.
2
Choose a provider
Select Twilio or Plivo.
3
Enter the details
Enter a Name For Phone Number, your provider credentials (Account SID and Auth Token for Twilio, or Auth ID and Auth Token for Plivo), and the phone number.
4
Import
Select Import Number. The number is active and ready to use.
2. Create a routing rule
A routing rule links your phone numbers to an agent:- Inbound: calls to the number are answered by the agent.
- Outbound: the agent places calls from the number, one at a time or through batch calls.
ZERORUNTIME_AGENT_ID, or the Agent ID printed by zeroruntime up on Zero Runtime Cloud.
- Dashboard
- API
1
Create the rule
Open Telephony → Routing Rules and select Create Routing Rule. Choose Inbound or Outbound, enter a Routing Rule Name, and select your phone numbers.
2
Add your agent
Under Agent Configuration, enter your agent’s ID in Agent Name or ID, then select Verify Agent ID.
3
Save
Select Create Rule.
3. Place a call
- Inbound
- Outbound
Call your number from any phone. The agent answers with its greeting from
on_enter.If the call isn’t answered, check that:- A worker is running.
- The number has an inbound routing rule with your agent’s ID.
- For BYOS, your carrier sends calls to the Inbound Gateway URL.
Troubleshooting
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 to Zero Runtime Cloud
Take your agent to production.