FastAPI + LangChain template for AI agent SaaS - full walkthrough
A production-tested template that wires FastAPI, LangChain, multi-tenant billing, RAG, and an admin dashboard so you can ship AI agent products in hours instead of weeks. Here's what it includes and how to deploy it.
Table of contents
AgentBoiler is a production-ready FastAPI + Next.js + LangChain template for AI agent SaaS applications. You buy the source code once, self-host on your own infrastructure, and ship a real product in hours instead of weeks.
This post walks through what’s in the box, the engineering choices that shape it, and how to go from git clone to a running agent in three commands.
What problem AgentBoiler solves
Every AI side-project starts with the same beautiful idea, then dies in week three when the founder realizes they need to wire up:
- JWT auth with refresh tokens
- Stripe Checkout, Customer Portal, and webhook signature validation
- Multi-tenant organizations with role-based access control
- A RAG pipeline (which vector store? which embedding model? which parser?)
- WebSocket streaming chat that survives Wi-Fi flips
- An admin dashboard with audit logs and refund actions
- Docker Compose + Nginx configs that actually work in production
That’s four to six weeks of plumbing before you’ve written a single line of your actual product. AgentBoiler ships all of it pre-wired.
What’s in the box
Backend (FastAPI)
- FastAPI 0.135+ with async PostgreSQL via asyncpg
- Repository → service → route layered architecture (no leaks)
- JWT access + refresh tokens, optional Google OAuth, magic links
- Alembic migrations with seeded admin user
- Redis caching, rate limiting, session management
- Celery background tasks with Flower monitoring
- Sentry + LangSmith tracing + structured logging (secret-redacted)
AI agents (LangChain + LangGraph)
- LangChain + LangGraph agent wired with WebSocket token streaming
- Tool calling registry - register Python functions as agent tools
- Conversation persistence + sharing + message ratings
- Token-level credit metering with per-model pricing: OpenAI, Anthropic, Google
RAG pipeline
- Milvus vector store with hybrid BM25 + vector search and reranking
- PDF / DOCX / MD / TXT parsers (PyMuPDF, LiteParse, LlamaCloud)
- Google Drive and S3 ingestion connectors with per-tenant scoping
- Continuous re-indexing on source changes
Multi-tenant billing
- Stripe Checkout + Customer Portal integration
- Hybrid billing: base subscription + usage-tracked credits
- Per-organization quotas with anomaly detection
- Stripe events log with replay action
- Transactional email via Resend
Frontend (Next.js)
- Next.js 15 App Router + React 19 + Tailwind v4 + shadcn/ui
- i18n via next-intl (English + Polish out of the box)
- Dark + light themes, accessibility-first components
- Marketing site (landing, blog MDX, pricing, FAQ, legal pages)
- Streaming chat UI with optimistic UI patterns
- Admin dashboard (users, orgs, subscriptions, audit log)
DevOps
- Docker Compose for dev / stage / prod environments
- Celery + Redis workers & beat (scheduled jobs) + Flower monitoring
- GitHub Actions CI (ruff, pytest + coverage, Playwright, pip-audit, Trivy)
- Nginx reverse proxy config + SSL ready
- Pre-commit hooks with ruff, ty, ESLint, prettier
From clone to running agent in three commands
git clone <your-agentboiler-repo>cd agentboilermake bootstrapmake bootstrap runs make dev + make seed:
- Builds the backend Docker image (cached after first run)
- Starts services via Docker Compose: Postgres, Redis, Milvus, MinIO, etcd, backend, Celery worker, Celery beat, Flower
- Polls Postgres until it’s ready
- Applies pending Alembic migrations
- Seeds an admin user (
admin@example.com/admin123)
In ~3 minutes you have a working chat UI streaming responses token-by-token from a LangChain + LangGraph agent, Stripe in test mode wired through with credits ticking down as you chat, and an admin API exposing users, orgs, subscriptions, usage, and audit log.
How AgentBoiler is different
In 30+ production AI agent deployments, the four-to-six-week plumbing tax is the single biggest cause of stalled projects - not model failures, not infra failures, just the boring scaffolding that every team rewrites from scratch. AgentBoiler exists so you don’t have to.
Compared to alternatives:
- vs ShipFast - ShipFast is Next.js + Mongo only, no FastAPI backend, no RAG, no multi-tenant orgs. Different audience (frontend-heavy AI demos vs production AI agent SaaS).
- vs FastSaaS - FastSaaS has FastAPI + Postgres but no AI / RAG / streaming. AgentBoiler is AI-first.
- vs LangChain free templates - LangChain ships a single framework with bare-minimum auth. AgentBoiler ships everything pre-wired including Stripe credits, multi-tenant orgs, and a full admin dashboard.
Pricing
$199 one-time purchase. ZIP download with full source code, commercial license for unlimited projects, lifetime access to the version you bought. Self-host on your own infrastructure - no AgentBoiler-hosted services required.
Frequently asked
What is an AI agent SaaS?
An AI agent SaaS is a multi-tenant web application where end users interact with an LLM-powered agent that can call tools, retrieve information from a knowledge base, and persist conversations. Examples include ChatGPT-clones with your own data, customer-support agents, code-review bots, and AI research assistants.
Do I need to know FastAPI and Next.js to use AgentBoiler?
Some familiarity helps. The template ships with a 5-minute setup (make bootstrap) that gets you a running chat UI with Stripe in test mode and a seeded admin user. From there you customize: change branding, add your domain logic, register your own LangChain tools, define your billing tiers.
Can I self-host AgentBoiler?
Yes - the entire stack runs in Docker with Compose configs for dev / stage / prod and a production Nginx reverse-proxy config. Self-host on Hetzner, AWS, GCP, Railway, or anywhere that runs containers. There are no AgentBoiler-hosted services required for the template to operate.
Is the source code obfuscated?
No. You receive plain, readable, type-annotated Python and TypeScript source code. Every file is open for inspection, modification, and extension. We ship the same source we use internally on production deployments.
Can I sell apps I build with AgentBoiler?
Yes - the commercial license permits use in unlimited commercial projects. You cannot redistribute the source code itself (including resale as a competing template), but anything you build on top is yours to monetize.