# Introduction

> What cairnflow is, and when to use it.

Source: https://cairnflow.dev/docs

Cairnflow runs your handlers durably. Every step — a model call, a tool call, a payment — is
recorded in a journal before the run moves on. When a process crashes, a deploy restarts your
service or a connection drops, the run resumes from the last recorded step instead of starting
over or running side effects twice.

You write ordinary TypeScript with the `@cairnflow/sdk` package, Python with the
[`cairnflow` package](/docs/develop/python), or Go with the [`cairn` package](/docs/develop/go).
Cairnflow calls your service over HTTP, keeps the
journal, the state and the timers, and decides when each run continues.

## What you can build

| Use case | What cairnflow gives you | Start with |
|---|---|---|
| **AI agents** | Model and tool calls as durable steps, tool approvals that wait on a durable promise, streams that reconnect after a reload, one turn at a time per chat | [Vercel AI SDK](/docs/agents/vercel-ai-sdk) |
| **Durable workflows** | Multi-step processes with one run per ID, waits of minutes or weeks, signals from outside | [Workflows](/docs/workflows/workflows) |
| **Stateful objects** | State per user, account or device behind a key, with one writer per key at a time | [Virtual objects and state](/docs/develop/state) |
| **Sagas and payments** | Recorded side effects, idempotency keys, compensation with `TerminalError` | [Errors and retries](/docs/develop/errors-retries) |
| **Schedules and background jobs** | Server-side cron with time zones, delayed sends, fan-out to child invocations | [Schedules](/docs/develop/schedules) |
| **Webhooks and events** | Acknowledge once durable, deduplicate with `Idempotency-Key`, concurrency and rate limits per scope | [Flow control](/docs/reference/flow-control) |

## Where your code runs

**On a long-running server** — a container, a VM or Kubernetes — with `serve()` on Node.js 22.6 or
newer. This is the best fit for agents: a replay cache keeps resumes cheap, and where HTTP/2 reaches
your service, one streaming connection per run carries tokens and cancellation as they happen. On
Cairnflow Cloud, streaming is opt-in; see [Deployments](/docs/cloud/deployments#transport).

**On a serverless function** — Vercel, Cloudflare Workers or AWS Lambda — with `fetchHandler`, the
Fetch adapter, which Deno and Bun can serve too. This fits short workflows: a few steps with
retries and timers, on the platform you already deploy to. See
[Serverless](/docs/workflows/serverless).

## How it is built

All of cairnflow's state lives on object storage — an S3-compatible bucket. The runtime nodes keep
nothing on disk: a node takes ownership of a range of keys with a lease, and when it dies another
node takes the range over from the bucket. A run is acknowledged only after its step is durable in
the bucket.

## Next

- [Quickstart](/docs/quickstart) — a first durable run on your own machine.
- [Concepts](/docs/concepts) — services, virtual objects, workflows and the journal.
