fastapi
Installation
SKILL.md
FastAPI
Official FastAPI skill to write code with best practices, keeping up to date with new versions and features.
Quick Reference
- Serve frontend apps: use
app.frontend()orrouter.frontend()for built frontend assets; see Serve Frontend Apps. - Server-Sent Events (SSE): use
response_class=EventSourceResponseandyield; see Streaming and the streaming reference. - JSON Lines and byte streaming: see the streaming reference.
- Dependencies: use
Annotated[..., Depends(...)]; see Dependency Injection and the dependency injection reference foryield, scopes, and class dependencies. - Response models: prefer return types; use
response_modelwhen the public response schema differs from the internal return value; see the response reference. - Pydantic models: do not use ellipsis or
RootModel; see the Pydantic reference. - Routing: declare router-level prefix, tags, and shared dependencies on the
APIRouter; see the path operation reference. - Tooling and related libraries: use uv, Ruff, ty, Asyncer, SQLModel, and HTTPX when applicable; see the other tools reference.
Use the fastapi CLI
Run the development server on localhost with reload: