python-fastapi

A Python web framework for building APIs, with automatic data checking and OpenAPI documentation. OpenAPI is a standard description of an API that tools can use to show and test its endpoints.

In plain words
What is it for?
Use it to build asynchronous Python APIs with authentication, database access, models, routers, startup and shutdown handling, and tests.
Why use it?
It reduces the manual work of validating API data and documenting what each endpoint accepts and returns.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/plazmodium/odin-workflow/python-fastapi
Any agent
npx skills add Plazmodium/odin-workflow --skill python-fastapi
Clone the repo
git clone --depth 1 https://github.com/Plazmodium/odin-workflow

Made for: Claude Code, Codex.

Per session 19 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,005 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00019 $0.01005
Opus 5 $0.00010 $0.00502
Sonnet 5 $0.00004 $0.00201
Haiku 4.5 $0.00002 $0.00101

Measured today against content hash 22d54a9d40cf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-fastapi 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 today.

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.

agents/skills/backend/python-fastapi/SKILL.md · 141 lines

How it starts

The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python FastAPI

Overview

FastAPI is a modern, high-performance Python web framework for building APIs. It uses Python type hints for automatic validation, serialization, and OpenAPI documentation.

Project Structure

src/
├── main.py                  # FastAPI app instance + startup
├── config.py                # Settings via pydantic-settings
├── routers/
│   ├── auth.py              # Auth endpoints
│   └── users.py             # User endpoints
├── models/
│   ├── user.py              # SQLAlchemy / ORM models
│   └── schemas.py           # Pydantic request/response schemas
├── services/
│   └── user_service.py      # Business logic
├── middleware/
│   └── auth.py              # Auth dependency
├── db/
│   ├── session.py           # Database session
│   └── migrations/          # Alembic migrations
└── tests/
    ├── conftest.py           # Fixtures
    └── test_users.py

Core Patterns

App Setup

from fastapi import FastAPI
from contextlib import asynccontextmanager

@asynccontextmanager
async def lifespan(app: FastAPI):
    # Startup
    await db.connect()
    yield
    # Shutdown
    await db.disconnect()

app = FastAPI(title="My API", lifespan=lifespan)
app.include_router(auth_router, prefix="/auth", tags=["auth"])
app.include_router(users_router, prefix="/users", tags=["users"])

Pydantic Schemas

from pydantic import BaseModel, EmailStr, Field

class UserCreate(BaseModel):
    email: EmailStr
    password: str = Field(min_length=8)
    name: str = Field(max_length=100)

class UserResponse(BaseModel):
    id: int
    email: str
    name: str

    model_config = {"from_attributes": True}  # ORM mode

Dependency Injection

from fastapi import Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer

oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/auth/token")

async def get_current_user(token: str = Depends(oauth2_scheme)) -> User:
    payload = decode_jwt(token)
    if not payload:
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
    user = await user_service.get_by_id(payload["sub"])
    if not user:
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND)
    return user

# Use in endpoint
@router.get("/me", response_model=UserResponse)
async def get_me(user: User = Depends(get_current_user)):
    return user

Read the full file on GitHub · 141 lines

Changes

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.

  1. today First seen · 141 lines · 19 tokens per session scan A 22d54a9d40cf

Subscribe to this mod's changes

python-fastapi is a skill published in the GitHub repository Plazmodium/odin-workflow (0 stars, last pushed 3mo ago), licensed MIT. It adds 19 tokens to every session and 1,005 once invoked, about $0.0001 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-09-01.