← All notes

async def vs def in FastAPI

Answer: You can mix def and async def in your path operation functions as much as you need and define each one using the best option for you. In any of the cases, FastAPI will still work asynchronously and be extremely fast. (S1)

The rules

Related

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: FastAPI docs, Concurrency and async / await - FastAPI, MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE); FastAPI docs, First Steps - FastAPI, MIT (fastapi/fastapi LICENSE; Copyright (c) 2018 Sebastián Ramírez; https://github.com/fastapi/fastapi/blob/master/LICENSE).

Cite this

Permanent ID: iil:note:hznwdxfr

iinventedlight. 2026. "async def vs def in FastAPI." iinventedlight Library, iil:note:hznwdxfr, version of 2026-11-04. https://iinventedlight.com/library/notes/fastapi-async-await/. License: CC-BY-4.0.

@misc{iil_note_hznwdxfr,
  author = {{iinventedlight}},
  title = {{async def vs def in FastAPI}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/fastapi-async-await/},
  note = {Permanent ID iil:note:hznwdxfr. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/fastapi-async-await.md.