Skip to content
All recipes
Python API

Deploy FastAPI API

A containerized FastAPI service with an explicit health route and optional PostgreSQL-backed state.

Why use it

Publish a typed HTTP API with interactive docs, predictable container startup and a database only when the service keeps records.

Build plan

  1. Build from an official Python image, install locked dependencies first and copy the application second.
  2. Run one FastAPI process on 0.0.0.0:8000 and add a lightweight GET /health route.
  3. Create managed PostgreSQL only when the API keeps records, then run and verify its migrations before sharing the address.

Resources and values

Resources
1 ServicePostgreSQL when stateful
Required values
DATABASE_URL when statefulApplication secret names
Check before you deploy

The old tiangolo/uvicorn-gunicorn-fastapi base image is deprecated. Build the application image from an official Python base instead.

Ask your coding agent

Prepare this FastAPI repository for aidrop. Add a production Dockerfile based on an official Python image, install the locked dependencies before copying the application and run one FastAPI process on 0.0.0.0:8000. Add GET /health without changing existing API behaviour. If the service keeps records, create managed PostgreSQL, store DATABASE_URL as a Project value and run the existing migrations; otherwise do not add a database. Deploy, verify /health and /docs, then return the public address without printing secrets.

Put FastAPI API online

Connect your coding agent, paste the quickstart and keep the build, runtime and public address in one aidrop Project.

7 days free · No credit card required