# FastAPI — card for AI agents

High-performance Python web framework with automatic API docs and async support.

Category: HTTP servers and APIs · PyPI package `fastapi` · latest version 0.162.0 (checked 2026-11-01)
Install: `pip install fastapi`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## FastAPI
- Install with `uv add "fastapi[standard]"`, keeping the extra in quotes. With pip, install `fastapi[standard]` inside a virtual environment.
- Use `fastapi dev` for local work (auto-reload). Use `fastapi run` for production.
- Declare path, query and body inputs as typed function parameters. A default of `= None` makes a parameter optional. Without it the parameter is required.
- Model JSON request bodies as Pydantic `BaseModel` classes and take them as a typed parameter.
- Use `async def` for a path function only if your code uses `async` / `await`. Otherwise use plain `def`.
- On 0.143.0 or later, if the app relies on `OTEL_*` environment variables for exporters, set `FASTAPI_OTEL_AUTO_CONFIGURE=true` or pass `telemetry={"auto_configure": True}`.
- Check the generated docs at `/docs` or `/redoc` after adding endpoints.

## Agent Skills for it
- fastapi-python from debpalash/VoiceStudio: `npx skills add debpalash/VoiceStudio --skill fastapi-python`
- fastapi-templates from wshobson/agents: `npx skills add wshobson/agents --skill fastapi-templates`
- fastapi-expert from Jeffallan/claude-skills: `npx skills add Jeffallan/claude-skills --skill fastapi-expert`
- fastapi-python from midudev/autoskills: `npx skills add midudev/autoskills --skill fastapi-python`
- fastapi-router-py from microsoft/skills: `npx skills add microsoft/skills --skill fastapi-router-py`
- fastapi-pro from rmyndharis/antigravity-skills: `npx skills add rmyndharis/antigravity-skills --skill fastapi-pro`

## Docs written for agents
- [llms.txt (index of the docs)](https://docs.railway.com/llms.txt)

## What it is
- FastAPI is a Python web framework for building APIs. The README describes it as "a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints." The repository was created on 2018-12-08 and is MIT licensed. It is built on two other libraries: Starlette for the web parts and Pydantic for the data parts.
- You write ordinary functions and attach them to paths with decorators such as `@app.get("/items/{item_id}")`. The parameter types decide what FastAPI reads from the path, query string or JSON body. Request bodies are declared as Pydantic `BaseModel` classes. The same declarations produce an OpenAPI schema, served as interactive docs at `/docs` (Swagger UI) and `/redoc` (ReDoc).
- It suits Python developers who want typed API endpoints without learning a separate schema language. The README says: "You don't have to learn a new syntax, the methods or classes of a specific library, etc." Install it with `uv add "fastapi[standard]"` and start a local server with `fastapi dev`.

## Caveats
- Speed-to-code and bug figures are internal estimates: The README claims about 200% to 300% faster feature development and about 40% fewer developer-induced errors. A footnote says these numbers come from the team's own internal tests, not from an independent study.
- 0.143.0 changed OpenTelemetry defaults: The project is still on 0.x versions, and release 0.143.0 is marked as breaking. Automatic exporter setup from `OTEL_*` variables is now opt-in. Apps that relied on it must set a flag. Apps that configure their own providers and exporters need no changes.
- Starlette and Pydantic sit underneath: FastAPI delegates the web layer to Starlette and data handling to Pydantic. Request bodies are Pydantic models, so you will be working with Pydantic directly as well as with FastAPI.
- Quote the install extra: The docs warn that the `[standard]` extra must be quoted, or the install command may not work in every shell.
- fastapi dev is for local work only: `fastapi dev` runs with auto-reload for local development. Its own startup banner points to `fastapi run` for production.

## Numbers (AgentGid data)
- Gid Score: 91.1 (#8 of all tools, 1 of 102 in its category)
- Used in 465 public projects set up for AI coding agents (7.4%)
- Downloads last week: 136,135,888 (as of 2026-11-24), +17.5% over 4 weeks
- GitHub stars: 104,951 (as of 2026-11-24)
- Last push: 2026-11-18

## Often used with
Uvicorn 92.5%, Pydantic 63.4%, python-dotenv 48.0%, python-multipart 36.3%, Requests 33.1%, Pydantic Settings 31.8%

## Checked alternatives (same job)
- Flask: https://agentgid.com/tools/flask/agent.md
- Starlette: https://agentgid.com/tools/starlette/agent.md
- Tornado: https://agentgid.com/tools/tornado/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/fastapi/
- Homepage: https://github.com/fastapi/fastapi
- Repository: https://github.com/fastapi/fastapi
- Source: https://github.com/fastapi/fastapi#readme
- Source: https://github.com/fastapi/fastapi
- Source: https://github.com/fastapi/fastapi/releases
- Source: https://fastapi.tiangolo.com/


## FastAPI: build the server side of an app in Python

FastAPI is a free Python framework for the server part of a website or app, the part that receives orders, sign-ups or uploads and answers them. You describe what each request must contain with plain Python types. FastAPI then checks incoming data, sends clear errors and makes a live docs page where you can try every request.

### Where to use it
- Server for a web or mobile app: Your front end or phone app sends orders, sign-ups and searches to a small Python server that checks each one and answers.
- A docs page to try every request: Open /docs in the browser and send test requests by hand; front-end developers and AI assistants see what the server expects.
- Photo and file uploads: People upload a photo or a document from a form; your server receives it without filling the memory with big files.
- Send the email after answering: After a sign-up the visitor gets the answer at once, and the welcome email goes out a moment later in the background.
- Put an AI model behind a web address: Wrap a Python model or an LLM call in one route, so your site, a chat widget or another service can ask it questions. (idea, not from the official pages)
- Read a slow file in the background: A user uploads a big spreadsheet; the server answers "accepted" right away and works through the file afterwards.

### How to start
- Install FastAPI with its standard extras (server, form and upload parsing, the fastapi command) into a virtual environment.

```
uv add "fastapi[standard]"
```

- Write main.py with one route that returns a dictionary.

```
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}
```

- Run it with fastapi dev while you build, and with fastapi run on the real server.

```
fastapi dev
```


### License
Free to use, also in paid and closed-source products, under the MIT license. Keep the copyright and license notice with copies of FastAPI you ship.

### Good to know
- Versions are still 0.x, and new middle numbers can break code. In October 2026 alone several releases changed how forms, empty fields and defaults are read.
- The docs ask you to pin the exact version that works for your app and to upgrade on purpose.
- The /docs page loads its scripts and styles from an outside file host by default; you can serve them yourself.
- Background tasks run inside the same server; long heavy jobs need a separate job queue.
- The makers also sell hosting called FastAPI Cloud, and the standard install adds its deploy command. Hosting anywhere else works too.

Checked 2026-11-11 against: https://github.com/fastapi/fastapi/blob/master/README.md, https://github.com/fastapi/fastapi/blob/master/LICENSE, https://pypi.org/pypi/fastapi/json, https://fastapi.tiangolo.com/, https://fastapi.tiangolo.com/tutorial/first-steps/, https://fastapi.tiangolo.com/tutorial/request-files/, https://fastapi.tiangolo.com/tutorial/background-tasks/, https://fastapi.tiangolo.com/tutorial/cors/, https://fastapi.tiangolo.com/tutorial/testing/, https://fastapi.tiangolo.com/async/, https://fastapi.tiangolo.com/fastapi-cli/, https://fastapi.tiangolo.com/deployment/versions/, https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/, https://fastapi.tiangolo.com/advanced/opentelemetry/, https://fastapi.tiangolo.com/release-notes/

### Mistakes to avoid
- Don't: pip install fastapi, then fastapi dev or a route with UploadFile / Form → Do: pip install "fastapi[standard]==0.162.4" (quoted), or add python-multipart yourself (The plain package leaves out the server, the fastapi command and the form parser; uploads need python-multipart.)
- Don't: fastapi>=0.100 or an unpinned fastapi in requirements.txt → Do: fastapi[standard]==0.162.4, then read the release notes before each minor upgrade (Minor versions carry breaking changes; 0.147 to 0.162 changed how omitted booleans, empty strings and unselected files in forms are read.)
- Don't: async def routes that call a blocking library (requests, most database drivers) → Do: Use plain def for routes that call blocking code; keep async def for code that awaits (Blocking calls inside async def stop the whole server from answering other requests meanwhile.)
- Don't: Query(custom="value") or other unknown keyword arguments copied from older examples → Do: Query(json_schema_extra={"custom": "value"}) (Since 0.155.0 unknown keyword arguments raise TypeError at startup.)
- Don't: CORSMiddleware with allow_origins=["*"] and cookies or Authorization headers → Do: List your real front-end origins and set allow_credentials=True (A wildcard origin excludes requests that carry credentials, so logged-in calls from the browser fail.)

### Questions
- Which Python version do I need? Python 3.10 or newer for FastAPI 0.162.4; support for 3.9 was dropped in February 2026.
- Do I need async and await? No. Plain def functions work; the docs say to use plain def when a library you call cannot await.
- Does FastAPI send data about my app anywhere? Not by default. It records traces and metrics, but since 0.143.0 it sends them only when you turn on automatic setup and give it an address.
- Can I use it in a paid product? Yes. It is MIT-licensed; keep the license notice with copies you ship.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
