# Quickstart

> Install a release binary or run Docker, start a node on your own machine, and run a first durable invocation in two minutes.

Source: https://cairnflow.dev/docs/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.

:::note
Cairnflow Cloud is in early-access waitlist — [join the waitlist](/#pricing). Until it opens, you
run the runtime yourself, as this page does.
:::

## 1. Install and start a node

**Option A — Prebuilt binaries** (Linux x86_64 below; the
[releases page](https://github.com/cairnflowdev/cairnflow/releases) has Linux arm64 and macOS arm64
too):

```sh
A=cairnflow-v0.1.0-beta.0-x86_64-unknown-linux-musl
mkdir -p ~/.local/bin                                  # or any directory on your PATH
curl -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 reach
```

**Option B — Docker:**

```sh
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-auth
cairn() { docker exec cairnflow cairn "$@"; }          # the CLI is in the container
```

Four 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](/docs/self-hosting#build-from-source).

## 2. Write a service

In a second terminal, install `@cairnflow/sdk` (zero runtime dependencies):

```sh
mkdir greeter && cd greeter
npm init -y && npm pkg set type=module
npm install @cairnflow/sdk
```

A 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.

```ts title="service.ts"

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:

```sh
node service.ts
```

`serve()` 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](/docs/self-hosting/security#request-identity-signed-calls-to-your-services).

To write the service in Python or Go, see [Python SDK](/docs/develop/python) (`pip install cairnflow`)
and [Go SDK](/docs/develop/go) (`go get github.com/cairnflowdev/cairnflow/sdk/go`). On Vercel or
AWS Lambda, the same service runs behind `fetchHandler`: see [Serverless](/docs/workflows/serverless).

## 3. Register and invoke

In a third terminal, register the deployment so Cairnflow reads its services and handlers, then
invoke `greet`:

```sh
cairn register http://127.0.0.1:9080      # with Docker: http://host.docker.internal:9080
cairn 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

Every step of the run is recorded. Inspect it with the `cairn` CLI:

```sh
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

`--no-auth` is only for local development on a machine only you reach. Without it, every route
except `/health` requires an API key:

```sh
export CAIRNFLOW_ADMIN_KEY="cf_$(openssl rand -hex 24)"   # bootstrap key, at least 32 bytes
export CAIRNFLOW_TOKEN="$CAIRNFLOW_ADMIN_KEY"              # key sent by the `cairn` CLI
cairnflow                                                   # same directory, same data
```

For 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.

## Next

- [Concepts](/docs/concepts)
- [Build an agent with the Vercel AI SDK](/docs/agents/vercel-ai-sdk)
- [Self-hosting](/docs/self-hosting): buckets, clusters, security and operations.
