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.
npx agentmods add rules/wassim249/fastapi-langgraph-agent-production-ready-template/project-main-rulesgit 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.svg" alt="Measured on agentmods" 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 | $0.01055 | $0.01055 |
| Sonnet 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 6d 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.
- 6d 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,639 stars, last pushed 20d ago), licensed MIT. It adds 2,109 tokens to every session, about $0.0105 per session on Opus 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
architectural-and-structural-rules
The project follows a layered architecture with clear separation of concerns.
api-design-and-implementation
API Design and Implementation Rules for FastAPI Endpoints.
testing-and-security
Testing and Security Guidelines for FastAPI Applications Including Unit Testing, Environment Variable Management, and Authentication Security.
020-flask
Flask API Gateway conventions for LMForge.
simplify
Structural-quality review of changed code — score against the four-dimension rubric, gate at 10/10, and (in auto-fix mode or with --fix) apply reuse/simplification/efficiency/altitude cleanups. Includes a diff-economy lens; correctness is /validate, full-repo survey is /audit.
statusline
Turn the usage statusLine on or off (model + context% + 5-hour usage% in every project) without editing config by hand. Runs bin/install-statusline.sh, which installs the script to /.claude and merges the setting without clobbering other keys. Opt-in, global, run once per machine; /statusline off disables it.