Skip to content
GitHub Get Started
General

Quickstart

Use this pre-built prompt to get started faster.
Prefer to read code? Clone the example repository.View on GitHub
OSClientJS · Browser · BackendServerOS= agentOS VM
  1. Install

    • @rivet-dev/agentos — Actor framework with built-in persistence and orchestration
    • @agentos-software/piPi coding agent (Claude Code, Amp, and OpenCode coming soon)
    Terminal window
    npm install @rivet-dev/agentos @agentos-software/pi
  2. Create the server

    server.ts
    import { agentOS, setup } from "@rivet-dev/agentos";
    import pi from "@agentos-software/pi";
    const vm = agentOS({
    software: [pi],
    });
    export const registry = setup({ use: { vm } });
    registry.start();
  3. Create the client

    The client can be any public frontend or another backend. The same vm actor is reachable from a plain Node script, a browser/React app, or a separate server.

    TypeScript
    import { createClient } from "@rivet-dev/agentos/client";
    import type { registry } from "./server";
    const client = createClient<typeof registry>({ endpoint: "http://localhost:6420" });
    const handle = client.vm.getOrCreate("my-agent");
    // Subscribe to streaming events. The payload is inferred from the event schema.
    const conn = handle.connect();
    conn.on("sessionEvent", (data) => {
    console.log(data.event);
    });
    // Create a session and send a prompt
    const session = await handle.createSession("pi", {
    env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY! },
    });
    await handle.sendPrompt(
    session.sessionId,
    "Write a hello world script to /home/user/hello.js",
    );
    // Read the file the agent created
    const content = await handle.readFile("/home/user/hello.js");
    console.log(new TextDecoder().decode(content));
  4. Run it

    Start the server, then run the client in a second terminal:

    Terminal window
    # Terminal 1: start the server
    npx tsx server.ts
    # Terminal 2: run the client
    npx tsx client.ts
  5. Customize

    Now that you have a working agent, customize it to fit your needs:

The quickstart above uses @rivet-dev/agentos, which includes statefulness, multiplayer, and orchestration out of the box. If you only need direct VM control without those features, you can use the core package (@rivet-dev/agentos-core) standalone.

See agentOS core documentation for reference.