fastapi

fastapi is a skill for Claude Code, Codex from ashish7802/awesome-api-skills. It costs 0 tokens per session (551 once invoked), scanned A, original, MIT.

A guide to FastAPI, a Python framework for building web APIs. It uses Python type hints to validate data and generate OpenAPI documentation.

In plain words
What is it for?
Building Python web APIs, generating documentation, injecting database or authentication services, and choosing synchronous or asynchronous route handlers.
Why use it?
It helps structure API endpoints, dependencies, database connections, and error handling so services are easier to test and operate.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

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/ashish7802/awesome-api-skills/fastapi
Any agent
npx skills add ashish7802/awesome-api-skills --skill fastapi
Clone the repo
git clone --depth 1 https://github.com/ashish7802/awesome-api-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for fastapi

README.md
[![agentmods](https://agentmods.dev/badge/skills/ashish7802/awesome-api-skills/fastapi.svg)](https://agentmods.dev/skills/ashish7802/awesome-api-skills/fastapi)
Your own site
<a href="https://agentmods.dev/skills/ashish7802/awesome-api-skills/fastapi"><img src="https://agentmods.dev/badge/skills/ashish7802/awesome-api-skills/fastapi.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 551 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.1 $0.00000 $0.00551
Opus 5 $0.00000 $0.00275
Sonnet 5 $0.00000 $0.00110
Haiku 4.5 $0.00000 $0.00055

Measured 6d ago against content hash d608803804d1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

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 6d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (examples/dependency.py, examples/main.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/fastapi/SKILL.md · 66 lines

How it starts

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

FastAPI Skill

High-performance Python web framework.

Ecosystem Graph

graph LR
  fastapi["FastAPI"]
  fastapi -- "alternative to" --> express
  fastapi -- "integrates with" --> openai
  fastapi -- "deploys to" --> docker

Quick Start

FastAPI leverages Python type hints to generate OpenAPI documentation automatically and serialize data incredibly fast using Pydantic.

pip install fastapi uvicorn pydantic

Production Patterns

Dependency Injection

Use the Depends() feature heavily. Inject database sessions, authenticators, and external clients directly into your route functions rather than relying on global state. This makes unit testing trivial by overriding dependencies.

Architecture & Scaling

Async vs Sync

FastAPI handles both def and async def routes. If you are using a synchronous database driver (like psycopg2), declare the route as def so FastAPI runs it in an external threadpool. If using an asynchronous driver (like asyncpg), use async def.

Error Recovery

Raise HTTPException inside your routes for expected errors (e.g., 404). For unexpected global errors, register a global exception handler via @app.exception_handler to sanitize the error response and log the stack trace to Sentry.

Security Notes

Use OAuth2PasswordBearer for built-in token extraction. Never expose raw SQL queries; always use an ORM like SQLAlchemy or SQLModel to prevent SQL injection.

Relationships

Alternatives: express

Works Well With: openai

Deploys To: docker

References

Why use this skill

Use this when your agent works with fastapi — structured patterns beat pasted docs and prevent common hallucinations.

AI pitfalls

  • Using outdated SDK or API versions from training data
  • Inventing environment variable names
  • Omitting error handling and retry logic

Production checklist

  • Secrets in environment variables, not source code
  • Error handling and logging in place
  • Rate limits and timeouts configured

Read the full file on GitHub · 66 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 6d ago First seen · 66 lines · 0 tokens per session scan A d608803804d1

Subscribe to this mod's changes

fastapi is a skill published in the GitHub repository ashish7802/awesome-api-skills (13 stars, last pushed 5d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 551 tokens. 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-08-30.

Related

Other skills, from other repositories

pycse

Skill "pycse" from ItamarZand88/awesome-agent-conventions, covering pycse - python computations in science and engineering, core capabilities, 1. nonlinear regression and curve fitting, 2. design of experiments (doe) and 3. uncertainty quantification with dpose.

ItamarZand88/awesome-agent-conventions · 0 tokens

implementation-strategy

Choose compatibility-aware scope for runtime and API changes in openai-agents-python. Use before initial implementation and each review-feedback batch to decide whether to patch, reset the design, preserve compatibility, or reject unsupported cases.

openai/openai-agents-python · 47 tokens

maintainer-review

Assess an openai-agents-python GitHub issue or pull request as a maintainer. Use to verify the claimed need and practical impact, compare supported alternatives or competing approaches, separate code quality from repository readiness, recommend the maintainer action, and draft a copy-ready comment when evidence…

openai/openai-agents-python · 69 tokens

python-package-management

Guide for managing packages in the Agent Framework Python monorepo, including creating new connector packages, versioning, and the lazy-loading pattern. Use this when adding, modifying, or releasing packages.

microsoft/agent-framework · 43 tokens

temporal-python-testing

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.

wshobson/agents · 45 tokens

python-feature-lifecycle

Guidance for package and feature lifecycle in the Agent Framework Python codebase, including stage meanings, feature-stage decorators, feature enums, and how to move APIs from one stage to the next.

microsoft/agent-framework · 43 tokens