Requirements
- Node.js 20.11+
- A Zero Runtime auth token from the dashboard
- API keys for the providers you use
Install
tsx, JavaScript needs no build step at all. Every
provider ships with the SDK; most need no extra package, because their credential is a string
you set in the environment.
Connect to the Runtime
Point the worker at your runtime address, and set your auth token, using the values from the dashboard:.env from the working directory if you add import 'dotenv/config'; at the
top of your entrypoint.
Conventions
- The SDK is ESM-only. Use
"type": "module"in yourpackage.json, or.mjs/.tsfiles. - Agents subclass
Agentand implement theasync on_enter()andon_exit()hooks. Names mirror the Python SDK, so options and hooks aresnake_casein both. Pipelineand every provider are factory calls, not constructors — nonew— and each takes a single options object, for exampleGoogleLLM({ model: 'gemini-2.5-flash' }).- Core APIs (
Agent,Pipeline,Room,Sip,serve,invoke,function_tool) are imported from@zeroruntime/js-sdk. - Provider plugins come from
@zeroruntime/js-sdk/plugins(direct to the vendor, with your key) or@zeroruntime/js-sdk/inference(the same providers through the Zero Runtime gateway, with only your Zero Runtime token). The names mirror each other, so swapping the import swaps who makes the call and who is billed. - Tools are built with
function_tool({ name, description, parameters, execute }). JavaScript cannot read parameter types at runtime, so you describe them yourself. A tool assigned to a field on your agent class is registered automatically; tools defined elsewhere go in thetoolsarray. - Inside a hook or tool,
this.session!is the liveSession. Outside the class, reach it withcurrent_session().
Example
main.ts
npx tsx main.ts. The playground URL is printed once, on stdout — open it to talk
to the agent.
Pass the agent class to
serve(), not an instance. serve() builds a fresh agent and
pipeline per call, which is what keeps per-call state correct under concurrent calls.API reference
Node JS SDK API reference
Every export, type, and option in the Node JS SDK.