The short answer
To deploy a FastAPI app with Postgres for free, give your coding agent the sentence below. Antideploy finds FastAPI in your requirements, starts it with uvicorn, and creates a Postgres database if your code needs one. The Free plan includes 1 live app with a server and 1 Postgres database, with no card. Your requirements must list uvicorn.
Say this to your coding agent
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
What Antideploy detects
-
FastAPI. Detected from
fastapiinrequirements.txtorpyproject.toml. The shallowest one is used. -
The start command.
uvicorn module:app --host 0.0.0.0 --port $PORT. The module is found by looking for the file that containsapp = FastAPI(. If none is found, it usesmain. -
The port. It starts the app with
PORTset, and the start command uses it. -
The Python version. From
.python-version,runtime.txtorrequires-pythoninpyproject.toml. -
The database. A
psycopgorasyncpgrequirement means Postgres, and SQLAlchemy is recognised too. With Alembic in your requirements,alembic upgrade headruns before the new version goes live.
What your project needs
fastapi
uvicorn
psycopg[binary]
sqlalchemy
alembic
import os
from fastapi import FastAPI
from sqlalchemy import create_engine
app = FastAPI()
engine = create_engine(os.environ["DATABASE_URL"])
@app.get("/health")
def health():
return {"ok": True}
If uvicorn is not in your requirements, Antideploy warns you that the app will build but will not start. Add it before you deploy. You do not need to set the host or port in code, because the start command passes 0.0.0.0 and PORT.
Step by step
-
Check the requirements
fastapianduvicornare listed, and the database is read fromDATABASE_URL. -
Paste the sentence and approve one link
Your agent creates the app and the database, writes the connection details into your
.envwithout printing them, and builds against the real database. -
Deploy and open the link
Antideploy installs your requirements, runs
alembic upgrade headif you use Alembic, starts the app and checks that it answers. Your agent tells you the address. FastAPI's/docspage is available on it.
Common problems
-
The app builds but never starts.
uvicornis missing from your requirements. See never started listening. -
No matching version. A pinned package has no build for the Python version in use. Pin another Python in
.python-version. See Could not find a version that satisfies the requirement. -
No module named. The code imports a package that is not in your requirements. See ModuleNotFoundError.
-
A SQLite file resets. The disk is replaced on every deploy. Use Postgres.