Converting a FastAPI Project's Dependencies

Convert a FastAPI application's requirements.txt to pyproject.toml, including async dependencies, Pydantic v2, database drivers, and background task workers.

Real-World Projects

Detailed Explanation

FastAPI projects typically leverage async Python extensively. Their dependency lists include ASGI servers, async database drivers, and Pydantic for data validation.

FastAPI requirements.txt:

fastapi>=0.104
uvicorn[standard]>=0.24
pydantic>=2.5
pydantic-settings>=2.1

# Database
sqlalchemy[asyncio]>=2.0
asyncpg>=0.29
alembic>=1.13

# Auth
python-jose[cryptography]>=3.3
passlib[bcrypt]>=1.7
python-multipart>=0.0.6

# Background Tasks
celery[redis]>=5.3
arq>=0.25

# Monitoring
sentry-sdk[fastapi]>=1.39
prometheus-fastapi-instrumentator>=6.1

Converted to pyproject.toml:

[project]
name = "my-fastapi-app"
version = "0.1.0"
requires-python = ">=3.11"

dependencies = [
    "fastapi>=0.104",
    "uvicorn[standard]>=0.24",
    "pydantic>=2.5",
    "pydantic-settings>=2.1",
    "sqlalchemy[asyncio]>=2.0",
    "asyncpg>=0.29",
    "alembic>=1.13",
    "python-jose[cryptography]>=3.3",
    "passlib[bcrypt]>=1.7",
    "python-multipart>=0.0.6",
    "celery[redis]>=5.3",
    "arq>=0.25",
    "sentry-sdk[fastapi]>=1.39",
    "prometheus-fastapi-instrumentator>=6.1",
]

FastAPI-specific patterns:

  • uvicorn[standard] is essential for production -- it adds httptools, uvloop, and websockets
  • Pydantic v2 uses a separate pydantic-settings package for configuration management
  • asyncpg is the preferred async PostgreSQL driver, while sqlalchemy[asyncio] provides the async ORM layer
  • python-jose[cryptography] uses the cryptography backend for JWT handling
  • passlib[bcrypt] provides bcrypt password hashing with the bcrypt backend

FastAPI's ecosystem is heavily async-first, so requires-python should typically be set to >=3.11 or higher to take advantage of task groups and other modern async features.

Use Case

Converting a production FastAPI microservice with async database access, JWT authentication, and Celery workers from requirements.txt to pyproject.toml.

Try It — Requirements ↔ Pyproject

Open full tool