> ## Documentation Index
> Fetch the complete documentation index at: https://docs.checkfu.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Checkfu is open source (https://github.com/checkfu/checkfu) and runs in the reader's own Cloudflare account. There is no shared hosted base URL: `checkfu deploy` prints the deployment's API URL (`https://<api-worker>.workers.dev` or the CHECKFU_API_DOMAIN hostname, exported as `CHECKFU_BASE_URL` for the CLI, SDK, and curl) and MCP URL (`.../mcp`). Local development serves the API on http://localhost:1337 and MCP on http://localhost:1338/mcp.
> Authenticated HTTP requests send the deployment's CHECKFU_API_KEY as `Authorization: Bearer $CHECKFU_API_KEY` (or `x-api-key`) and `Content-Type: application/json` for JSON bodies. Pass `Idempotency-Key` on retriable writes.
> Core workflow: create an Agent (`POST /v1/agents`) and an Environment (`POST /v1/environments`), create a Session that references both (`POST /v1/sessions`), send a `user.message` event (`POST /v1/sessions/{session_id}/events`), and follow `GET /v1/sessions/{session_id}/events/stream` until `session.status_idle`.
> Other resources: Memory stores (`/v1/memory_stores`), Files (`/v1/files`), Artifacts (`/v1/artifacts`), Vaults and credentials (`/v1/vaults`), Provider credentials (`/v1/provider_credentials`), Automations (`/v1/automations`), Inbound bindings (`/v1/inbound_bindings`), and Webhooks (`/v1/webhooks`). The deployment serves its OpenAPI 3.1 specification at `GET /openapi.json`.

# Quickstart

> Deploy Checkfu to your Cloudflare account, create an Agent, and talk to it in a Session.

In about five minutes you will deploy Checkfu, create an Agent, and talk to it from the CLI and from TypeScript.

You need Node.js 22 or later, a Cloudflare account on Workers Paid with R2 enabled, and an API key for Anthropic, OpenAI, or OpenRouter. To try Checkfu without Cloudflare, [start it locally](https://github.com/checkfu/checkfu#development), run `checkfu --base-url http://127.0.0.1:1337 login` with your local API key, and skip to step 2.

**1. Deploy Checkfu**

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
npm install -g checkfu
export ANTHROPIC_API_KEY=sk-ant-...   # or OPENAI_API_KEY / OPENROUTER_API_KEY
checkfu deploy
```

`deploy` signs you in to Cloudflare, deploys the server, and saves the API URL and a generated API key in your configuration directory for subsequent CLI commands. (If you deploy without exporting a provider key, open the Dashboard after deploy and add a model provider credential under **Vaults**.)

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Checkfu is live at https://<api-worker>.workers.dev

  API key    saved to /path/to/checkfu/config.json
  API docs   https://<api-worker>.workers.dev/openapi.json
  Dashboard  https://<app-worker>.workers.dev
  MCP        https://<mcp-worker>.workers.dev/mcp
```

Run `checkfu deploy` again to update the same deployment. See [Deploy](https://docs.checkfu.com/self-hosting/deploy.md).

**2. Create an Agent and an Environment**

An [Agent](https://docs.checkfu.com/concepts/agents.md) is the model and instructions. An [Environment](https://docs.checkfu.com/concepts/environments.md) is where its Sessions run. Export `CHECKFU_MODEL_ID` to make the model your deployment can call available to both the CLI and TypeScript examples.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
AGENT_ID=$(checkfu agents create --name Assistant --model "$CHECKFU_MODEL_ID" --transform id -r)
ENVIRONMENT_ID=$(checkfu environments create --name default --transform id -r)
```

`--transform id -r` prints only the new ID.

**3. Start a Session and talk to it**

A [Session](https://docs.checkfu.com/concepts/sessions.md) is one conversation. It keeps its history and `/workspace` files between turns.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
SESSION_ID=$(checkfu sessions create --agent "$AGENT_ID" --environment-id "$ENVIRONMENT_ID" --transform id -r)
checkfu sessions connect "$SESSION_ID"
```

Ask the agent to write a file in `/workspace` and read it back. Run `connect` again later to pick up where you left off, or watch the Session in the [Dashboard](https://docs.checkfu.com/dashboard.md).

**4. Do the same from TypeScript**

Install the SDK and set `CHECKFU_CONNECTION_FILE` to the saved `config.json` path printed by `checkfu deploy` or `checkfu login`.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
npm install @checkfu/sdk
export CHECKFU_CONNECTION_FILE='/path/to/checkfu/config.json'
```

Save this as `quickstart.mts` and run `npx tsx quickstart.mts` to create a Session, send a message, and stream the reply.

```ts quickstart.mts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import Checkfu from "@checkfu/sdk"
import { readFile } from "node:fs/promises"

async function readConnection() {
  try {
    const file = process.env.CHECKFU_CONNECTION_FILE
    if (file === undefined) throw new Error()
    const saved: unknown = JSON.parse(await readFile(file, "utf8"))
    if (
      typeof saved === "object" && saved !== null &&
      "url" in saved && typeof saved.url === "string" &&
      "api_key" in saved && typeof saved.api_key === "string" &&
      saved.api_key.length > 0 && !/[^!-~]/u.test(saved.api_key)
    ) {
      const url = new URL(saved.url)
      if (
        (url.protocol === "http:" || url.protocol === "https:") &&
        !url.username && !url.password && !url.search && !url.hash
      ) {
        return { baseUrl: saved.url, apiKey: saved.api_key }
      }
    }
  } catch {
    // Report one message for unreadable or invalid records.
  }
  throw new Error("Set CHECKFU_CONNECTION_FILE to the config.json path printed by checkfu deploy or checkfu login.")
}

const client = new Checkfu(await readConnection())

const agent = await client.waitForPending(
  await client.agents.create({ name: "Assistant", model: process.env.CHECKFU_MODEL_ID! }),
)
const environment = await client.waitForPending(
  await client.environments.create({ name: "default" }),
)
const session = await client.waitForPending(
  await client.sessions.create({ agent: agent.id, environment_id: environment.id }),
)

await client.sessions.events.send(session.id, {
  events: [{ type: "user.message", content: [{ type: "text", text: "Write a short status report." }] }],
})

for await (const event of await client.sessions.events.stream(session.id)) {
  if (event.type === "agent.message") {
    console.log(event.content.map((block) => block.text).join(""))
  }
  if (event.type === "session.status_idle" && event.stop_reason.type === "requires_action") {
    console.log("Waiting for tool answers", event.stop_reason.event_ids, "resume after", event.seq)
    break
  }
  if (event.type === "session.status_idle" || event.type === "session.status_terminated") break
}
```

If a turn requests tool answers, submit them from your application or the dashboard, then resume the stream after the reported sequence. See [Tools](https://docs.checkfu.com/concepts/tools.md) and [Resume a stream](https://docs.checkfu.com/guides/resume-a-stream.md).

Writes can return HTTP `202` before the read view catches up; `waitForPending` returns settled resources immediately and polls [pending receipts](https://docs.checkfu.com/reference/http-api.md#pending-receipts) until they are ready.

## Next steps

> [card] [Sessions](https://docs.checkfu.com/concepts/sessions.md)
>
> Events, turns, mounts, and outputs.

> [card] [Tools](https://docs.checkfu.com/concepts/tools.md)
>
> Built-in tools, MCP servers, and custom tools.

> [card] [Agents as code](https://docs.checkfu.com/guides/agents-as-code.md)
>
> Keep Agents in your repository and apply them.

> [card] [Add an agent to your app](https://docs.checkfu.com/guides/add-an-agent-to-your-app.md)
>
> Run Sessions from your backend and stream them to users.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.