Skip to main content

Requirements

  • Node.js 20.11+
  • A Zero Runtime auth token from the dashboard
  • API keys for the providers you use

Install

The package ships compiled JavaScript plus complete type declarations, so both languages are first class: TypeScript runs directly with 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:
The SDK reads a .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 your package.json, or .mjs/.ts files.
  • Agents subclass Agent and implement the async on_enter() and on_exit() hooks. Names mirror the Python SDK, so options and hooks are snake_case in both.
  • Pipeline and every provider are factory calls, not constructors — no new — and each takes a single options object, for example GoogleLLM({ 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 the tools array.
  • Inside a hook or tool, this.session! is the live Session. Outside the class, reach it with current_session().

Example

main.ts
Run it with 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.
The Quickstart shows a complete agent. Runnable examples are at zeroruntime-js-examples.