Quickstart
This page runs everything on one machine: a cairnflow node, a small service, and the calls between them.
You need:
- a Cairnflow runtime — a prebuilt release archive below, or Docker (no Rust, no database);
- Node.js 22.18 or newer, which runs TypeScript files directly (Node.js 22.6 to 22.17 works with
node --experimental-strip-types) — or Python ≥ 3.11 or Go ≥ 1.25.
1. Install and start a node
Section titled “1. Install and start a node”Option A — Prebuilt binaries (Linux x86_64 below; the releases page has Linux arm64 and macOS arm64 too):
A=cairnflow-v0.1.0-beta.0-x86_64-unknown-linux-muslmkdir -p ~/.local/bin # or any directory on your PATHcurl -L "https://github.com/cairnflowdev/cairnflow/releases/download/v0.1.0-beta.0/$A.tar.gz" \ | tar -xz -C ~/.local/bin --strip-components=1 "$A/cairnflow" "$A/cairn" "$A/cairn-ctl" "$A/cairn-query-worker"cairnflow --no-auth # dev switch: no API key, for a machine only you reachOption B — Docker:
docker run -d --name cairnflow -p 127.0.0.1:8080:8080 \ --add-host=host.docker.internal:host-gateway \ -v cairnflow-data:/var/lib/cairnflow \ ghcr.io/cairnflowdev/cairnflow:v0.1.0-beta.0 --no-authcairn() { docker exec cairnflow cairn "$@"; } # the CLI is in the containerFour self-contained binaries ship together: cairnflow (the runtime), cairn (the CLI),
cairn-ctl (the operator tool) and cairn-query-worker. The node listens on 127.0.0.1:8080
(8081 is for other nodes), keeps all state under ./cairnflow-data, and serves the web console
at http://127.0.0.1:8080/ui/. To compile from source instead, see
Build from source.
2. Write a service
Section titled “2. Write a service”In a second terminal, install @cairnflow/sdk (zero runtime dependencies):
mkdir greeter && cd greeternpm init -y && npm pkg set type=modulenpm install @cairnflow/sdkA service is a set of handlers. ctx.run journals the result of a step: after a crash or retry,
the step is replayed from the journal instead of running again.
import { serve, service } from "@cairnflow/sdk";
const greeter = service("Greeter", { greet: async (ctx, name: string) => { // Journaled: a retry after a crash does not run it again. const upper = await ctx.run("upper", () => name.toUpperCase()); return `Hello, ${upper}!`; },});
await serve({ services: [greeter], port: 9080 });Start it and leave it running:
node service.tsserve() listens on 127.0.0.1 by default, which is all a node on the same machine needs. When
running the runtime in Docker, pass hostname: "0.0.0.0" in serve() so the container can reach
your service. It prints a warning that identityKeys is not set: a service that other machines can
reach should check that requests really come from your node. See
Request identity.
To write the service in Python or Go, see Python SDK (pip install cairnflow)
and Go SDK (go get github.com/cairnflowdev/cairnflow/sdk/go). On Vercel or
AWS Lambda, the same service runs behind fetchHandler: see Serverless.
3. Register and invoke
Section titled “3. Register and invoke”In a third terminal, register the deployment so Cairnflow reads its services and handlers, then
invoke greet:
cairn register http://127.0.0.1:9080 # with Docker: http://host.docker.internal:9080cairn invoke Greeter greet --input '"world"'The answer carries the invocation ID and the handler’s output, "Hello, WORLD!". To fire and
forget over HTTP, call POST http://127.0.0.1:8080/invoke/Greeter/greet/send instead: you get the
invocation ID back as soon as it is durable.
4. Read the journal
Section titled “4. Read the journal”Every step of the run is recorded. Inspect it with the cairn CLI:
cairn journal <invocation ID>It lists the input, the step and its result, and the output. Open http://127.0.0.1:8080/ui/ in a
browser to inspect journals, timelines and traces visually, retry or cancel runs, and query
invocations with SQL.
5. Turn authentication on
Section titled “5. Turn authentication on”--no-auth is only for local development on a machine only you reach. Without it, every route
except /health requires an API key:
export CAIRNFLOW_ADMIN_KEY="cf_$(openssl rand -hex 24)" # bootstrap key, at least 32 bytesexport CAIRNFLOW_TOKEN="$CAIRNFLOW_ADMIN_KEY" # key sent by the `cairn` CLIcairnflow # same directory, same dataFor production, point the node at an S3-compatible bucket instead of a local directory:
--main-store s3://my-bucket/prefix with the usual AWS_* environment variables.
- Concepts
- Build an agent with the Vercel AI SDK
- Self-hosting: buckets, clusters, security and operations.