FastAPI in Production: Settings, Auth, Middleware, and Project Structure
Harden a FastAPI app for production: typed settings with pydantic-settings, bearer auth, logging and CORS middleware, and a scalable project structure.
Ad blocker or privacy protection detected
Ads and Google Analytics may be blocked. You can allow this site in your browser or extension settings, then reload; the site still works if you continue.
Writing
Long-form writing on development, tooling, and lessons from the workbench plus book reviews when a title sticks.
Topics
Jump to a category or open all categories.
Newest first. Use search or categories above to narrow down.
Harden a FastAPI app for production: typed settings with pydantic-settings, bearer auth, logging and CORS middleware, and a scalable project structure.
Call language models from Python with the Claude SDK: the messages loop, tokens and cost, and a client with timeouts and retries you can inject and test.
Build a small AI agent API: the tool calling loop, conversation memory, and the guardrails that keep an action taking agent safe and bounded.
Stream a real model response to the browser: consume the model stream in Python, forward it through a FastAPI SSE endpoint, and render it live.
Get dependable JSON from language models with structured outputs and function calling, then validate with Pydantic so your code works with typed objects.
Stream responses from FastAPI with server sent events, run side effects with BackgroundTasks, and know when to move to a real task queue.
Build a RAG service end to end: chunk documents, embed and search by similarity, and answer grounded in retrieved context from a FastAPI endpoint.
A balanced, hands-on look at Claude Fable 5: how Anthropic's new flagship compares to Opus 4.8 and Sonnet 4.6 on price, context, and capabilities, and when the 2x premium is and is not worth paying.