Skip to main content
General

Quickstart (Embedded)

Run a coding agent in an embedded agentOS VM from an existing Node.js application.

Use the embedded API when you want to run agentOS directly inside an existing Node.js application without Rivet Actors. Your application owns VM identity, persistence, and lifecycle.

Choosing between Actors and embedded

Use Rivet Actors when you want agentOS to manage persistence, distributed state, sleep and wake, multiplayer, and orchestration. Use the embedded API when your application needs direct VM control and will own those responsibilities itself.

Embedded APIActor
PersistenceIn-memory unless you configure database, plus mountsActor SQLite injected automatically
Distributed stateManage yourselfBuilt-in
Stateful VMsComplex to run yourselfBuilt into Rivet
Sleep/wakeManual dispose() / create()Automatic
EventsDirect in-process callbacksBroadcast to every connected client
Preview URLsServe them from your own applicationBuilt-in signed URL server
MultiplayerFan out from your own applicationMultiple clients per actor
OrchestrationVM-local cron while the VM is aliveWorkflows, queues, and cron
Agent-to-agentBindings between VMs you ownBuilt into Rivet Actors
AuthenticationYour application’s ownDocs

Quick Start

Install

Install the core VM API and the Pi coding agent:

npm install @rivet-dev/agentos-core @agentos-software/pi

Set your model API key

export ANTHROPIC_API_KEY=your-api-key

Create an embedded VM

import pi from "@agentos-software/pi";
import { AgentOs } from "@rivet-dev/agentos-core";

const apiKey = process.env.ANTHROPIC_API_KEY;
if (!apiKey) {
	throw new Error("Set ANTHROPIC_API_KEY before running this example.");
}

const vm = await AgentOs.create({ software: [pi] });

try {
	await vm.sessions.open({
		agent: "pi",
		env: { ANTHROPIC_API_KEY: apiKey },
	});

	await vm.sessions.prompt({
		content: [
			{
				type: "text",
				text: "Create /home/agentos/hello-world.js that prints hello world.",
			},
		],
	});

	const script = await vm.filesystem.readFile("/home/agentos/hello-world.js");
	console.log(new TextDecoder().decode(script));
} finally {
	await vm.dispose();
}

Run it

npx tsx quickstart.ts

AgentOs.create() returns a VM handle directly. There is no actor server or separate client, and the VM stays alive until you call dispose().

See Embedded VMs for lifecycle, persistence, configuration, and the shared sidecar, plus links to each capability page’s Embedded API section. Use the actor quickstart when you want built-in persistence, sleep and wake, multiplayer, preview URLs, and orchestration.