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.
Place a phone call
PassSip(...) instead of a playground room to start the session on an outbound call. You
need an outbound gateway set up first.
Connect to the phone network
To take or place phone calls, set up gateways in the Zero Runtime dashboard or API, and a routing rule that points at your agent ID. Your worker must be running to receive calls.Set up inbound calls
Set up inbound calls
1. Create an inbound gateway: the entry point for incoming calls.2. Create a routing rule: connects the inbound gateway to your agent.3. Test it: with your worker running, dial your provider’s phone number from any phone. The agent greets you as soon as the call connects.
- Dashboard
- API
- 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.
- Dashboard
- API
- From your inbound gateway, click Configure rule, then Create new routing rule.
- Enter a Routing Rule Name and select API Key authentication.
- Choose the Call Direction (Inbound).
- Enter the Phone Number and select a Room Type.
- Enter your
ZERORUNTIME_AGENT_IDas the Agent ID and click Save.
Set up outbound calls
Set up outbound calls
1. Create an outbound gateway: lets the agent dial out to the PSTN.2. Place a call: with your worker running, trigger a call with the SDK or the API. Replace
- Dashboard
- API
- In Twilio, open your SIP Trunk and go to the Termination section. Create a Termination URI and add username/password credentials.
- Back in the Zero Runtime Dashboard, open the outbound gateway configuration.
- Paste the Twilio Termination URI as the address, add the same username/password credentials, and save.
YOUR_ZERORUNTIME_AUTH_TOKEN and routingRuleId with your own.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.
References
- Python
- Node JS
Examples
Cascade Basic
Smallest complete agent showing serve + invoke.