# AI Agent SaaS Kit · Atlas

> Atlas, a full-stack AI agent workspace you can sell, with credits and Stripe billing.

The OTF **AI Agent SaaS Kit** (Atlas) is a web app and API for selling your own AI agent product.
Agents have instructions, a model, tools, skills, files and memory. They chat with streaming replies,
ask each other, work together in team rooms and track tasks, and every reply is paid for from a
credits ledger tied to Stripe. Live at [ai-app.otf-kit.dev](https://ai-app.otf-kit.dev): click
**Try the demo account** to open a seeded workspace.

## Stack

| Layer     | Choice                                                                                   |
| --------- | ---------------------------------------------------------------------------------------- |
| Framework | Vite 6 + React 19 (SPA)                                                                   |
| Routing   | TanStack Router (hand-wired in `src/main.tsx`)                                            |
| Data      | TanStack Query                                                                            |
| Server    | Hono 4 on one Cloudflare Worker (Bun for self-hosting), streaming replies over SSE        |
| DB        | Postgres 16 + pgvector, Drizzle ORM                                                       |
| Auth      | Better Auth: magic link and Google, an optional password, demo login                      |
| AI        | Vercel AI SDK with Anthropic, OpenAI, Google, OpenRouter, Mistral, DeepSeek and Ollama; a built-in demo provider needs no key |
| Payments  | Stripe Checkout, Customer Portal and webhooks: Free, Pro and Team plans plus credit packs |
| Email     | Resend with React Email templates                                                         |
| Files     | Cloudflare R2 for uploads and generated images                                            |
| UI        | `@otfdashkit/ui` on the OTF design tokens, dark and light                                 |

## What it does

- **Agents**: instructions, a model, tools (docs search, images, web fetch), files and per-agent memory. Eight seeded agents ship with their own avatars, and Hire an agent adds one from a template with a first task.
- **Skills**: like Claude's. A skill is a `SKILL.md` with a name, a description and instructions. Write one, upload a `.md` or `.zip`, or import it from GitHub, then switch it on per agent. The agent loads a skill when a task matches it, or when you type `/name` in a chat.
- **Agents working together**: an agent can ask another and show the answer in the chat, an `@mention` brings another agent in, and a team room lets a lead agent hand out the work and post one status.
- **Chat**: streaming replies with a trace of each step and its credit cost, steering while the agent works, a queue for messages that wait until the turn ends, replies that quote a message, and approval cards when an agent needs your OK.
- **Tasks**: hand off work, follow it on a status page, and start the tasks your agents suggest.
- **Scheduled tasks**: repeating or one-time, with run history.
- **Docs and images**: document search with page citations, and an image studio.
- **Credits**: monthly grants, top-ups and refunds on failure, with an admin console for users, credits and model prices.
- **Bring your own models**: workspace API keys (encrypted at rest), or, when self-hosted, the owner's Claude Code, Codex or Gemini CLI plan.

## Credits

`server/lib/pricing.ts` is the one price list: plans, packs, per-model reply costs and tool costs.
A reply debits credits before the model call and refunds them if every route fails. Plans and
packs are bought through Stripe; webhooks grant each period's credits once.

## Adding things

The kit's `ai/prompts/` folder has task prompts for common changes: add an agent template, add a
tool, add a model or provider, change credit costs, add a plan or a credit pack, handle a new
Stripe event, and more. `CLAUDE.md` and `AGENTS.md` document the conventions.

## Deploy

`bash scripts/deploy-worker.sh` builds the web app and deploys the app and API as one Cloudflare
Worker, with a cron trigger for scheduled tasks. Put Hyperdrive in front of Postgres (Neon works)
and bind an R2 bucket for files. The `Dockerfile` runs it on any container host instead. Run
`bun run db:migrate` and `bun run db:seed` from your machine. The deployment guide ships with the kit.

## Required env

| Variable             | Purpose                                                        |
| -------------------- | -------------------------------------------------------------- |
| `DATABASE_URL`       | Postgres connection string (or the Hyperdrive binding)          |
| `BETTER_AUTH_SECRET` | 32+ chars, signs sessions and tokens                            |
| `BETTER_AUTH_URL`    | Public origin, for example `https://your-app.com`               |

Optional: model provider keys, `KEY_ENCRYPTION_SECRET` to save workspace keys, `STRIPE_SECRET_KEY`
and `STRIPE_WEBHOOK_SECRET` for billing, `RESEND_API_KEY` and `RESEND_FROM` for email,
`GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` for Google sign-in, and `DEMO_LOGIN_ENABLED=1` for
the one-click demo.

## Buy

<DocsBundleBuyButton source="docs_kit_page" />


[$99 on otf-kit.dev](https://otf-kit.dev/templates/ai-saas-kit) — or get the
[Everything Bundle](/docs/templates/starter-bundle) ($149 = 6 delivered Live kits + all 20 landing templates; $774 separately, save $625.)
