
fastapi
FastAPI Python framework. Covers REST APIs, validation, dependencies, security. Use when building Python web APIs with FastAPI, configuring Pydantic models, implementing dependency injection, or setting up OAuth2/JWT authentication. Keywords: FastAPI, Pydantic, async, OAuth2, JWT, REST API.
- Installs
- 96
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/itechmeat/llm-code --skill fastapi- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads fastapi automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
FastAPI
This skill provides comprehensive guidance for building APIs with FastAPI.
Quick Navigation
| Topic | Reference |
|---|---|
| Getting started | references/first-steps.md |
| Path parameters | references/path-parameters.md |
| Query parameters | references/query-parameters.md |
| Request body | references/request-body.md |
| Validation | references/validation.md |
| Body advanced | references/body-advanced.md |
| Cookies/Headers | references/cookies-headers.md |
| Pydantic models | references/models.md |
| Forms/Files | references/forms-files.md |
| Error handling | references/error-handling.md |
| Path config | references/path-config.md |
| Dependencies | references/dependencies.md |
| Security | references/security.md |
| Middleware | references/middleware.md |
| CORS | references/cors.md |
| Database | references/sql-databases.md |
| Project structure | references/bigger-applications.md |
| Background tasks | references/background-tasks.md |
| Metadata/Docs | references/metadata-docs.md |
| Testing | references/testing.md |
| Advanced responses | references/responses-advanced.md |
| WebSockets | references/websockets.md |
| Templates | references/templates.md |
| Settings/Env vars | references/settings.md |
| Lifespan events | references/lifespan.md |
| OpenAPI advanced | references/openapi-advanced.md |
When to Use
- Creating REST APIs with Python
- Adding endpoints with automatic validation
- Implementing OAuth2/JWT authentication
- Working with Pydantic models
- Adding dependency injection
- Configuring CORS, middleware
- Uploading files, handling forms
- Testing API endpoints
Installation
Requires Python 3.10+. Install: pip install "fastapi[standard]" (full with uvicorn) or pip install fastapi (minimal). Add python-multipart for forms/files.
Release Highlights (0.139.2 -> 0.141.1)
- Frontend dev experience (
0.141.0):check_dironapp.frontend()now defaults to"auto", which skips the frontend-directory existence check (with a warning) whenFASTAPI_ENV=developmentand enforces it otherwise.fastapi devsetsFASTAPI_ENV=developmentautomatically unless already set, so running the dev server before the frontend is built no longer raises an error. - Frontend fixes (
0.141.1): background tasks and response headers produced by dependencies used on frontend routes (dependency support was added in0.139.0) are now applied correctly instead of being silently dropped.FASTAPI_ENVis documented in the FastAPI CLI guide. - Dependency-injection memory refactor (
0.140.0–0.140.7): internal dependency trees are no longer repeatedly flattened for OpenAPI generation, request-parameter resolution, and body-field handling, reducing memory use in large applications; the internallru_cachelimit for dependency resolution was also raised to fit bigger apps. This is an internal optimization with no required code changes. - Streaming fixes (
0.140.8–0.140.13):include_router()no longer loses the declared stream item type from a nested router'syield-based endpoints;response_model_*params (e.g.response_model_exclude) are now honored on plain (non-generator) endpoints thatreturnanIterable[Model], not only onyield-based ones;status_codeset on SSE/JSONL streaming endpoints is now honored instead of always returning 200; a dedicated API reference page forfastapi.ssewas added. jsonable_encoderfix (0.140.9):exclude_defaultsnow propagates into dict keys and values, not only into top-level model fields.
Release Highlights (0.137.0 -> 0.139.2)
- Frontend serving (
0.138.0):app.frontend("/", directory="dist")serves a built static frontend directly from the FastAPI app.0.139.0adds dependencies support inapp.frontend(), enabling automatic cookie authentication for frontends, and0.139.1fixes fallback for dotted paths like/users/john.doe. - Router internals (
0.137.0):include_router()now preservesAPIRouter/APIRouteinstances instead of cloning routes, so routes added after inclusion are reflected automatically and memory use drops. CustomAPIRouter/APIRoutesubclasses gain.matches()/.handle()(alpha) for advanced routing. - Thread safety (
0.139.2): route building is refactored to be thread-safe, mainly relevant for tests running across parallel threads.
Release Highlights (0.133.0 → 0.136.1)
- 0.134.0: streaming JSON Lines and streaming binary data support using
yield. - 0.135.0: first-class Server-Sent Events (SSE) support (
EventSourceResponse). - 0.135.1: fix around
TaskGroupusage in request async exit stack (stability fix). - 0.136.1: FastAPI updates its Pydantic v2 code to avoid deprecations and bumps Starlette to
1.0.0.
Patch Notes (0.136.2 → 0.136.3)
- SSE responses now validate event fields more strictly, so malformed
ServerSentEventpayloads fail earlier instead of quietly streaming invalid frames. - Header parameters no longer accept underscore-named incoming headers when
convert_underscores=True(the default). If a client truly sends underscore headers, declareHeader(convert_underscores=False)and verify that your proxy chain allows them.
Quick Start
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str | None = None):
return {"item_id": item_id, "q": q}
Run: fastapi dev main.py
Core Patterns
Type-Safe Parameters
from typing import Annotated
from fastapi import Path, Query
@app.get("/items/{item_id}")
def read_item(
item_id: Annotated[int, Path(ge=1)],
q: Annotated[str | None, Query(max_length=50)] = None
):
return {"item_id": item_id, "q": q}
Request Body with Validation
from pydantic import BaseModel, Field
class Item(BaseModel):
name: str = Field(min_length=1, max_length=100)
price: float = Field(gt=0)
@app.post("/items/", response_model=Item)
def create_item(item: Item):
return item
Dependencies
from fastapi import Depends
async def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
@app.get("/users/")
def list_users(db: Annotated[Session, Depends(get_db)]):
return db.query(User).all()
Authentication
from fastapi.security import OAuth2PasswordBearer
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]):
return decode_token(token)
@app.get("/users/me")
def read_me(user: Annotated[User, Depends(get_current_user)]):
return user
API Documentation
- Swagger UI:
/docs - ReDoc:
/redoc - OpenAPI:
/openapi.json
Best Practices
- Use
Annotated[Type, ...]for parameters - Define Pydantic models for request/response
- Use
response_modelfor output filtering - Add
status_codefor proper HTTP codes - Use
tagsfor API organization - Add
dependenciesat router/app level for auth
Prohibitions
- ❌ Return raw database models (use response models)
- ❌ Store passwords in plain text (use bcrypt/passlib)
- ❌ Mix
BodywithForm/Filein same endpoint - ❌ Use sync blocking I/O in async endpoints
- ❌ Skip HTTPException for error handling
Links
FAQ
What does the fastapi skill do?
FastAPI Python framework. Covers REST APIs, validation, dependencies, security. Use when building Python web APIs with FastAPI, configuring Pydantic models, implementing dependency injection, or setting up OAuth2/JWT authentication. Keywords: FastAPI, Pydantic, async, OAuth2, JWT, REST API.
How do I install fastapi?
Run npx skills add https://github.com/itechmeat/llm-code --skill fastapi in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/fastapi/ (personal) or .claude/skills/fastapi/ (project).
Which AI agents can use fastapi?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is fastapi safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains fastapi?
It is published by itechmeat in itechmeat/llm-code. It has 96 recorded installs.
More from itechmeat/llm-code
react-testing-library
itechmeat/llm-code
React Testing Library: user-centric component testing with queries, user-event simulation, async utilities, and accessibility-first API. Use when writing React component tests, selecting elements by role/label/text, simulating user events, or testing async UI behavior. Keywords: React Testing Library, @testing-library/react, user-event, queries, render.
openspec
itechmeat/llm-code
OpenSpec artifact-driven workflow. Covers OPSX commands, schemas, project config. Use when applying the artifact-driven workflow (OPSX), planning or reviewing changes based on artifact dependencies, or working with OPSX commands and schema/template resolution. Keywords: OPSX, artifact graph, /opsx:.
mantine-dev
itechmeat/llm-code
Open the skill to read its SKILL.md instructions.
social-writer
itechmeat/llm-code
Open the skill to read its SKILL.md instructions.
base-ui
itechmeat/llm-code
Open the skill to read its SKILL.md instructions.
refine-dev
itechmeat/llm-code
Open the skill to read its SKILL.md instructions.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.