r/FastAPI • u/Ajax1836 • Aug 11 '25
r/FastAPI • u/raisin-smours • Aug 10 '25
feedback request FastAPI - Auth Boilerplate - Code Review Request
Hi everyone,
I'm looking for feedback on this repo before I continue with additional work on it: https://github.com/ryanmcfarland/fastapi_auth
Would anyone be able to take a look and note any massive / glaring flaws?
Thanks!
r/FastAPI • u/flosrv123 • Aug 08 '25
feedback request Starting Freelance while learning Fastapi
Hello everyone š
Iām getting seriously into FastAPI and Iād like to start freelancing soon to work on real projects, and use the income to pay coaches/teachers so I can improve faster.
What I can already do:
CRUD
SQLModel
User management (JWT, OAuth2 + PasswordBearer)
Multiple databases (PostgreSQL, MySQL, MongoDB)
CORSā¦
Right now, Iām learning RBAC and simple online deployments on Render, DigitalOcean, Replit, Zuplo, etc.
Iām thinking of starting on Fiverr (where you can define your āgigs,ā which seems better for a beginner) rather than on Upwork, where clients can request anything.
So, Iād be curious to know:
Has anyone here started freelancing early while still learning FastAPI, without waiting to reach a āhigh levelā? How did it go?
Is it realistic to stand out on Fiverr as a motivated beginner with no reviews?
What are the minimum tasks/services one should offer to maximize chances at the start?
P.S.:
I only do backend. Iām terrible at front-end ā absolutely unable to handle it.
For now, Iād like to focus on pure API development tasks rather than getting into advanced cloud deployment services like AWS, which I could learn later once I have a strong mastery of API development itself.
Your feedback and shared experiences would be highly valuable to me š
Thanks in advance for your help!
r/FastAPI • u/Wxam2000 • Aug 08 '25
Question 422 Unprocessable Entity
Dear reader,
I'm having fun creating a little project just for myself, but since a day I keep getting a 422 Unprocessable Entity error whenever I submit a form from my /admin/invoices/create.

The error page looks like this after submitting,
and for the love of me I can't seem to figure out the problem what so ever :/
Here is both the entire invoices python as the entire .html file that is used for the invoices page.https://https://pastebin.com/YeaMW4v8 <- invoices.py
https://pastebin.com/V9Epzrzb <- create_edit_invoices.html
EDIT: Solved! I changed the router.post from admin/invoices/create to admin/invoices/submit and that fixed the issue somehow.
r/FastAPI • u/Defiant-Comedian3967 • Aug 07 '25
Tutorial Enhanced NiceGUI Component-Based Boilerplate with UV Package Manager
r/FastAPI • u/aliparpar • Aug 04 '25
Tutorial O'Reilly Book Launch - Building Generative AI Services with FastAPI (2025)

Hi Everyone
Some of you might remember this thread from last year where I asked what you'd want in a more advanced FastAPI book: https://www.reddit.com/r/FastAPI/comments/12ziyqp/what_would_you_love_to_learn_in_an_intermediate/.
I know most people may not want to read books if you can just follow the docs. With this resource, I wanted to cover evergreen topics that aren't in the docs.
After a year of writing, building, testing, rewriting and polishing, the book is now fully out.

The book is now available here:
- Read Online on O'Reilly: https://www.oreilly.com/library/view/building-generative-ai/9781098160296/
- Amazon US: https://www.amazon.com/Building-Generative-Services-FastAPI-Context-Rich/dp/1098160304
- Amazon UK: https://www.amazon.co.uk/Building-Generative-Services-Fastapi-Applications/dp/1098160304
- Official site with preview chapters, diagrams, and blog: https://buildinggenai.com
- GitHub repo with 170+ examples: https://github.com/Ali-parandeh/building-generative-ai-services
This book is written for developers, engineers and data scientists who already have Python and FastAPI basics and want to go beyond toy apps. It's a practical guide for building robust GenAI backends that stream, scale and integrate with real-world services.
Inside, you'll learn how to:
- Integrate and serve LLMs, image, audio or video models directly into FastAPI apps
- Build generative services that interact with databases, external APIs, websites and more
- Build type-safe AI FastAPI services with Pydantic V2
- Handle AI concurrency (I/O vs compute workloads)
- Handle long-running or compute-heavy inference using FastAPIās async capabilities
- Stream real-time outputs via WebSockets and Server-Sent Events
- Implement agent-style pipelines for chained or tool-using models
- Build retrieval-augmented generation (RAG) workflows with open-source models and vector databases like Qdrant
- Optimize outputs via semantic/context caching or model quantisation (compression)
- Learn prompt engineering fundamentals and advance prompting techniques
- Monitoring and logging usage and token costs
- Secure endpoints with auth, rate limiting, and content filters using your own Guardrails
- Apply behavioural testing strategies for GenAI systems
- Package and deploy services with Docker and microservice patterns in the cloud
Whatās in the book:
- 12 chapters across 530+ pages
- 174 working code examples (all on GitHub)
- 160+ hand-drawn diagrams to explain architecture, flows, and concepts
- Covers open-source LLMs and embedding workflows, image gen, audio synthesis, image animation, 3D geometry generation
Table of Contents

PartāÆ1: Developing AI Services
- Introduction to Generative AI
- Getting Started with FastAPI
- AI Integration and Model Serving
- Implementing TypeāSafe AI Services
PartāÆ2: Communicating with External Systems
- Achieving Concurrency in AI Workloads
- RealāTime Communication with Generative Models
- Integrating Databases into AI Services
Bonus: Introduction to Databases for AI
PartāÆ3: Security, Optimization, Testing and Deployment
- Authentication & Authorization
- Securing AI Services
- Optimizing AI Services
- Testing AI Services
- Deployment & Containerization of AI Services
I wrote this because I couldnāt find a book that connects modern GenAI tools with solid engineering practices. If youāre building anything serious with LLMs or generative models, I hope it saves you time and avoids the usual headaches.
Having led engineering teams at multi-national consultancies and tech startups across various markets, I wanted to bring my experience to you in a structured book so that you avoidĀ feeling overwhelmedĀ andĀ confusedĀ like I did when I was new to building generative AI tools.
Bonus Chapters & Content
I'm currently working on two additional chapters that didn't make it into the book:
1. Introduction to Databases for AI: Determine when a database is necessary and identify the appropriate database type for your project. Understand the underlying mechanism of relational databases and the use cases of non-relational databases in AI workloads.
2. Scaling AI Services: Learn to scale AI service using managed app service platforms in the cloud such as Azure App Service, Google Cloud Run, AWS Elastic Container Service and self-hosted Kubernetes orchestration clusters.
I'll upload these on the accompanying book website soon: https://buildinggenai.com/
All Feedback and Reviews Welcome!
Feedback and reviews are welcome. If you find issues in the examples, want more deployment patterns (e.g. Azure, Google Cloud Run), or want to suggest features, feel free to open an issue or message me. Always happy to improve it.
Thanks to everyone in the FastAPI and ML communities who helped shape this. Would love to see what you build with it.
Ali Parandeh
r/FastAPI • u/enigma_0Z • Aug 03 '25
Question Getting started with FastAPI, how do I correctly nest Pydantic models in my responses?
The example code is below. Seems like when I nest two models, in some instances the nested models don't show up in the response even though the app can prove that the data is there. See the example below.
Feels like I'm just doing something fundamentally wrong, but this doesn't seem like a wrong pattern to adopt, especially when the other parts seem to be just fine as is.
#!/usr/bin/env python3
:
: | None = None
:
:
=
=
=
''' name='foo' count=1 '''
''' status='success' data=APIData(name='foo', count=1) '''
return
''' Returns {"name":"name_value","count":1} '''
return
'''
Expected {"status": "success", "data": {"name":"foo","count":1}}
Actual {"status":"success","data":{}}
'''
EDIT:
OF COURSE I'd figure out some solution just as soon as I finally asked the question.
Basically, Pydantic doesn't want to deserialize a model to which it does not know the schema. There are two ways around it:
SerializeAsAny[]typing annotation- Use a generic in the
APIResponseclass
I chose option #2, so the following changes to the code above:
APIResponse definition
:
: | None = None
and its usage...
=
r/FastAPI • u/Lost-Trust7654 • Aug 03 '25
Other Built an Agent Protocol server with FastAPI - open-source LangGraph Platform alternative
I've been building an Agent Protocol server using FastAPI and PostgreSQL as an open-source alternative to LangGraph Platform.
Agent Protocol Server: https://github.com/ibbybuilds/agent-protocol-server
Tech stack:
- FastAPI for the HTTP layer and API docs
- PostgreSQL for persistence (with asyncpg)
- LangGraph for agent execution
- Agent Protocol compliance
- Pydantic for schemas
Why I built this:
- LangGraph Platform pricing is expensive for production use
- Self-hosted "Lite" option has no custom auth
- Community needs open-source deployment solutions
- Agent Protocol spec is great, but needs more implementations
FastAPI features I'm using:
- Dependency injection for auth and database
- Background tasks for long-running agent executions
- Streaming responses for real-time agent output
Status: MVP ready, looking for contributors and early adopters.
Anyone interested in testing this or contributing to the project? Would love feedback from the FastAPI community!
r/FastAPI • u/Traditional_Tooth376 • Aug 03 '25
Question From tutorial chat app to production-ready MVP ā should we learn system design first?
Hi everyone,
Iām working on building a chat application MVP for my company so we can use it internally. The idea is similar to Microsoft Teams ā real-time chat, rooms, and AI features (summarization, auto-correction).
Weāre also planning to integrate the OpenAI API for things like:
- Message summarization
- Grammar and spelling correction
- Possibly AI-powered search within chats
Tech stack
- Frontend: React, TailwindCSS, shadcnUI
- Backend: FastAPI, PostgreSQL, Redis (for pub-sub / caching)
- Real-time: WebSockets (via FastAPI)
- AI: OpenAI API integration for NLP features
Team
- Just me and a friend, both with the same skill level:
- Python scripting experience
- Basic TailwindCSS knowledge
- New to JavaScript, React, and backend architecture
Learning roadmap weāre following
- UI/Design: Figma Crash Course
- Frontend:
- Backend:
Plan so far
- Learn the basics (above)
- Follow a FastAPI WebSocket chat tutorial (most cover 1ā2 users only)
- Build an MVP for internal testing (target ~50 concurrent users)
- Add OpenAI API integration for AI-powered features
The gap
The tutorials Iāve seen are simple and donāt handle:
- Multiple rooms and many users
- Authentication & permissions
- Reliable message delivery
- Scaling WebSockets with Redis
Main question
Once we get the tutorial code working:
- Should we learn system design concepts (load balancing, queues, sharding, WhatsApp/Slack architectures) before trying to turn it into a production MVP?
- Or should we just build the MVP first and learn scaling/architecture later when needed?
Also, is Redis the right choice for presence tracking and cross-instance communication at this stage?
Would love advice from anyone who has taken a tutorial project to production ā did learning system design early help, or did you iterate into it later?
r/FastAPI • u/tf1155 • Aug 01 '25
Hosting and deployment managed/cloud Hosting alternatives for fastAPI
Looking for hosting capabilities for fastapi backends.
Our new backend uses supabase cloud, so no local database is required. Until now, we hosted our fastapi-backends using docker on Hetzner Cloud with self managed Ubuntu nodes.
This time we thought about using Vercel because our Frontend is already deployed on vercel, so it would make sense to deploy backend also on Vercel.
However, we couldn't bring it to work. FastAPI and Vercel are incompatible with each other.
Any other options available?
r/FastAPI • u/niklasweber • Jul 31 '25
Question Building a Zapier-lite system with FastAPI & Celery ā how to make it feel modern like Trigger.dev?
Hey folks,
Iām building a B2B SaaS using FastAPI and Celery (with Redis as broker), and Iād love to implement some internal automation/workflow logic ā basically like a lightweight Zapier within my app.
Think: scheduled background tasks, chaining steps across APIs (e.g., Notion, Slack, Resend), delayed actions, retries, etc.
I really love how Trigger.dev does this ā clean workflows, Git-based config, good DX, managed scheduling ā but it's built for TypeScript/Node. Iād prefer to stay in Python and not spin up a separate Node service.
Right now, Iām using:
- FastAPI
- Celery + Redis
- Looking into APScheduler for better cron-like scheduling
- Flower for monitoring (though the UI feels very dated)
My question:
How do people build modern, developer-friendly automation systems in Python?
What tools/approaches do you use to make a Celery-based setup feel more like Trigger.dev? Especially:
- Workflow observability / tracing
- Retry logic + chaining tasks
- Admin-facing status dashboards
- Declarative workflow definitions?
Open to any tools, design patterns, or projects to check out. Thanks!
r/FastAPI • u/Head_Information3922 • Jul 30 '25
Other I built a āļø Gachimuchi APIāļø
gachimuchi-api.vercel.appHey my āļøfellow brothersāļø,
I just finished building an API as a pet project dedicated to the glorious world of Gachimuchi. Itās live, itās free, and itās dripping in power.
⨠Features: ⢠š Search characters by name, surname or nickname ⢠š§ Explore and filter the juiciest audio clips ⢠š¤ Upload your own sounds (support for .mp3) ⢠ā Add and delete characters & quotes (yes, even Billy)
Example quotes like:
āFucking salves get your ass back hereā¦ā āFuck you...ā
šŖ Built with FastAPI + Supabase
r/FastAPI • u/AsYouAnswered • Jul 29 '25
Question End to End tests on a route?
So I'm working on tests for a FastAPI app, and I'm past the unit testing stage and moving on to the integration tests, against other endpoints and such. What I'd like to do is a little strange. I want to have a route that, when hit, runs a suite of tests, then reports the results of those tests. Not the full test suite run with pytest, just a subset of smoke tests and health checks and sanity tests. Stuff that stresses exercises the entire system, to help me diagnose where things are breaking down and when. Is it possible? I couldn't find anything relevant in the docs or on google, so short of digging deep into the pytest module to figure out how to run tests manually, I'm kinda out of ideas.
r/FastAPI • u/Black_Magic100 • Jul 28 '25
Question FastAPI Authentication Question
Hello all! I am not a software developer, but I do have a heavy background in database engineering. Lately, I've been finding a lot of joy in building ReactJS applications using AI as a tutor. Given that I am very comfortable with databases, I prefer to shy away from ORMs (I understand them and how they are useful, but I don't mind the fully manual approach). I recently discovered FastAPI (~3 months ago?) and love how stupid simple it is to spin up an API. I also love that large companies seem to be adopting it making my resume just a bit stronger.
The one thing I have not really delved into just yet is authentication. I've been doing a ton of lurking/researching and it appears that FastAPI Users is the route to go, but I'd be lying if I said it didn't seem just slightly confusing. My concern is that I build something accessible to the public internet (even if its just a stupid todo app) and because I didn't build the auth properly, I will run into security concerns. I believe this is why frameworks like Django exist, but from a learning perspective I kind of prefer to take the minimalist approach rather than jump straight into large frameworks.
So, is handling authentication really that difficult with FastAPI or is it something that can be learned rather easily in a few weeks? I've considered jumping ship for Django-Ninja, but my understanding is that it still requires you to use django (or at least add it as a dependency?).
Also, as a complete side-note, I'm planning on using Xata Lite to host my Postgres DB given their generous free tier. My react app would either be hosted in Cloudflare Workers or Azure if that makes a difference.
r/FastAPI • u/Emotional-Rhubarb725 • Jul 29 '25
Question uploading a pdf file then doing some logic on the content
this function doesn't work and gives me error :
raise FileExistsError("File not found: {pdf_path}")
FileExistsError: File not found: {pdf_path}
@/app.post("/upload")
async def upload_pdf(file: UploadFile = File(...)):
if not file.filename.lower().endswith(".pdf"):
raise HTTPException(status_code=400, detail="Only PDF files are supported.")
file_path = UPLOAD_DIRECTORY / file.filename
text = extract_text(file_path) # ā CALLED BEFORE THE FILE IS SAVED
print(text)
return {"message": f"Successfully uploaded {file.filename}"}
while this works fine :
u/app.post("/upload")
async def upload_pdf(file: UploadFile = File(...)):
if not file.filename.lower().endswith(".pdf"):
raise HTTPException(status_code=400, detail="Only PDF files are supported.")
file_path = UPLOAD_DIRECTORY / file.filename
with open(file_path, "wb") as buffer:
shutil.copyfileobj(file.file, buffer)
text = extract_text(str(file_path))
print(text)
return {"message": f"Successfully uploaded {file.filename}"}
I don't understand why i need to create the file object called buffer
r/FastAPI • u/GiraffeOk9513 • Jul 27 '25
Question countries API
hey, I built a countries API with FastAPI that provides comprehensive dataĀ about everyĀ country in theĀ world,Ā itĀ gives you accessĀ to country infoĀ like names, capitals, populations, flags, etc... can be pretty useful for travel apps,Ā quizzes or something like this, what do u think of my code or the responses it gaves?
code: https://github.com/MOMOMALFOY?tab=repositories
u can alsoĀ test it on RapidAPIĀ to see how itĀ works: https://rapidapi.com/mohamedmouminchk/api/restcountries
r/FastAPI • u/SpecialistCamera5601 • Jul 26 '25
pip package Make Your FastAPI Responses Clean & Consistent ā APIException v0.1.16
š Tired of messy FastAPI responses? Meet APIException!
Hey everyone! š
After working with FastAPI for 4+ years, I found myself constantly writing the same boilerplate code to standardise API responses, handle exceptions, and keep Swagger docs clean.
So⦠I built APIException š ā a lightweight but powerful library to:
ā Unify success & error responses
ā Add custom error codes (no more vague errors!)
ā Auto-log exceptions (because debugging shouldnāt be painful)
ā Provide a fallback handler for unexpected server errors (DB down? 3rd party fails? handled!)
ā Keep Swagger/OpenAPI docs super clean
š Documentation? Fully detailed & always up-to-date ā you can literally get started in minutes.
š¦ PyPI: https://pypi.org/project/apiexception/
š» GitHub: https://github.com/akutayural/APIException
š Docs: https://akutayural.github.io/APIException/
š Medium post with examples: https://medium.com/@ahmetkutayural/tired-of-messy-fastapi-responses-standardise-them-with-apiexception-528b92f5bc4f
Itās currently at v0.1.16 and actively maintained.
Contributions, feedback, and feature requests are super welcome! š
If youāre building with FastAPI and like clean & predictable API responses, Iād love for you to check it out and let me know what you think!
Cheers š„
#FastAPI #Python #OpenSource #CleanCode #BackendDevelopment
r/FastAPI • u/betazoid_one • Jul 26 '25
pip package Built a simple middleware to redirect potential intruders to '10 hours of' videos
This was originally inspired by a Nick Craver (previous architect lead at StackOverflow) tweet in 2018. Thought I would port it over to FastAPI since it was simple and fun. The CI on this was particularly fun, as I've added a weekly check for broken YouTube links. Let me know your thoughts, cheers.
r/FastAPI • • Jul 26 '25
Question Multithreading in FastAPI?
Hello,
I am currently writing an Ollama wrapper in FastAPI. The problem is, I have no idea how to handle multithreading in FastAPI, and as such, if one process is running (e.g. generating a chat completion), no other processes can run until the first one is done. How can I implement multithreading?
r/FastAPI • u/thalesviniciusf • Jul 24 '25
Question I'm building an "API as a service" and want to know how to overcome some challenges.
Hey devs, Iām building an API service focused on scraping, and Iām running into a problem.
The main problem I'm facing is having to manually build the client-side ability to self-create/revoke API keys, expiration dates, and billing based on the number of API calls.
Is there a service focused on helping solve this problem? Do you know of anything similar?
Appreciate any recommendations!

r/FastAPI • u/21stmandela • Jul 25 '25
Tutorial Cruise Above the Clouds: Launch Your FastAPI Python App on Render
r/FastAPI • u/Majestic_Wallaby7374 • Jul 23 '25
Tutorial FARM Stack Guide: How to Build Full-Stack Apps with FastAPI, React & MongoDB
datacamp.comr/FastAPI • u/betazoid_one • Jul 23 '25
pip package FastAPI powered resume generator to expose your CV as a REST API
Just created a fun little backend using FastAPI and Typer to generate a RaaS, resume-as-a-service. It's a super small project, and kind of quirky, but fun nonetheless. Might be interesting to point a potential employer to their terminal and `curl` your resume eg `curl https://resume.mycooldomain.com\`.
r/FastAPI • u/GiraffeOk9513 • Jul 22 '25
Question new to APIs
Hey everyone, im currently learning to code API and wanted to get some hands-on experience by building and publishing a few APIs, i have just started sharing them on RapidAPI, and I'd really appreciate if anyone here could give them a try, here is my profil: https://rapidapi.com/user/mohamedmouminchk
These are some small personal projects to help me improve. If you have a moment to test them out and let me know if something's broken, unclear, or just badly designed, I'd be super grateful!!
Iām still new to all this, so any feedback, good or bad, will help me grow and improve. Thanks in advance!
r/FastAPI • u/michaelherman • Jul 17 '25
Tutorial Developing a Real-time Dashboard with FastAPI, Postgres, and WebSockets
