FastAPI LangGraph Agent Template is a starter codebase for building AI-agent backends with FastAPI and LangGraph, including conversation state, memory, tool calls, monitoring, rate limits, and authentication. AI engineers use it as a foundation for deploying agent services, and the catalogue instructions and rule support development and operation of those services.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
git clone --depth 1 https://github.com/wassim249/fastapi-langgraph-agent-production-ready-templateWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules)<a href="https://agentmods.dev/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules"><img src="https://agentmods.dev/badge/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules"><img src="https://agentmods.dev/badge/rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.02109 | $0.02109 |
| Opus 5.5 | $0.00844 | $0.00844 |
| Sonnet 5.5 | $0.00422 | $0.00422 |
| Haiku 4.5 | $0.00211 | $0.00211 |
Grade A, and why
project-main-rules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 220 lines — stays where its author put it; the contents beside it link to each section on GitHub.
LangGraph FastAPI AI Agent Development
You are an expert in building production-ready AI agent applications using Python, FastAPI, LangGraph, and LangChain.
This is a LangGraph FastAPI Agent Project for building scalable, secure AI agent services with LLM orchestration, observability, and persistence.
Project Architecture Overview
This is an AI agent application that:
- Uses LangGraph for building stateful, multi-step AI agent workflows
- Uses FastAPI for high-performance async REST API endpoints
- Integrates Langfuse for LLM observability and tracing
- Uses PostgreSQL with pgvector for long-term memory storage (mem0ai)
- Implements JWT authentication with session management
- Provides rate limiting with slowapi
- Includes Prometheus metrics and Grafana dashboards for monitoring
- Uses structlog for structured logging with environment-specific formatting
- Implements retry logic using tenacity library
- Uses rich library for colored, formatted console outputs
Key Principles
- Write concise, technical responses with accurate Python examples
- Use functional, declarative programming; avoid classes where possible except for services and agents
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (e.g.,
is_active,has_permission) - Use lowercase with underscores for directories and files (e.g.,
routers/user_routes.py) - Favor named exports for routes and utility functions
- Use the Receive an Object, Return an Object (RORO) pattern
- All imports must be at the top of the file - never add imports inside functions or classes
Python/FastAPI Conventions
- Use
deffor pure functions andasync deffor asynchronous operations - Use type hints for all function signatures; prefer Pydantic models over raw dictionaries
- File structure: exported router, sub-routes, utilities, static content, types (models, schemas)
- Use concise, one-line syntax for simple conditional statements (e.g.,
if condition: do_something()) - Avoid unnecessary else statements; use the if-return pattern instead
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 220 lines · 2,109 tokens per session scan A 3c0efd2b50c0
project-main-rules is a cursor rule published in the GitHub repository wassim249/fastapi-langgraph-agent-production-ready-template (2,718 stars, last pushed 6d ago), licensed MIT. It adds 2,109 tokens to every session, about $0.0084 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
api-design-and-implementation
API Design and Implementation Rules for FastAPI Endpoints.
app_layer_rules
App layer (API) contract for FastAPI endpoints in backend/apps. Parse/validate input, call services, map domain errors to HTTP, return JSONResponse on success.
service_layer_rules
Service layer implements core business logic orchestration; raise custom exceptions; no HTTP handling.
environment_variable
Centralize env var access in backend/consts/const.py; no direct os.getenv outside.
020-flask
Flask API Gateway conventions for LMForge.
040-api-security
Security, auth, and async tasks for LMForge API.