BlogFastAPI

How to deploy a FastAPI app with Postgres for free.

FastAPI deploys with one sentence. It needs uvicorn in your requirements, and it can use the free Postgres database Antideploy creates.

How the Agent API works
  • uvicornStarted with your module and the PORT variable
  • Postgres1 database on the Free plan
  • AlembicMigrations run before release
  • Free plan1 live app with a server

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 fastapi in requirements.txt or pyproject.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 contains app = FastAPI(. If none is found, it uses main.
  • The port. It starts the app with PORT set, and the start command uses it.
  • The Python version. From .python-version, runtime.txt or requires-python in pyproject.toml.
  • The database. A psycopg or asyncpg requirement means Postgres, and SQLAlchemy is recognised too. With Alembic in your requirements, alembic upgrade head runs before the new version goes live.

What your project needs

requirements.txt
fastapi
uvicorn
psycopg[binary]
sqlalchemy
alembic
main.py
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

  1. Check the requirements

    fastapi and uvicorn are listed, and the database is read from DATABASE_URL.

  2. Paste the sentence and approve one link

    Your agent creates the app and the database, writes the connection details into your .env without printing them, and builds against the real database.

  3. Deploy and open the link

    Antideploy installs your requirements, runs alembic upgrade head if you use Alembic, starts the app and checks that it answers. Your agent tells you the address. FastAPI's /docs page is available on it.

Common problems

01Before you commit

Here's where it stops.

A platform that only tells you what it is good at is one you find the edges of in production. These are the ones to know before your first deploy.

  1. Apps sleep when idle

    On every plan, an app nobody is using goes to sleep and the next visit wakes it. The first request took 2.9 to 13.9 seconds in our measurements, depending on the stack. There are no always-on workers, so use a cron job or a webhook for background work.

  2. One instance, no previews

    Each app is one instance with 1 shared vCPU and 1 GB of memory, and a Java app gets 1 dedicated vCPU and 2 GB. There are no preview deployments and no per-branch URLs.

  3. The disk forgets

    Anything written to local disk is gone on the next deploy. Apps that speak S3 get a bucket instead.

  4. 10 deploys a month on Free

    Only successful deploys of apps with a server count. Static sites never do, and a failed deploy is free.

02Questions

FastAPI questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
Is it really free?

The Free plan includes 1 live app with a server, 10 successful deploys a month and 1 Postgres database. It needs no card and has no trial clock. Failed deploys are free.

Why is the first request slow?

Apps sleep when idle. Measured on 19 September 2026, the first request after sleeping took 5.1 to 9.2 seconds for FastAPI, and the next request about 0.14 to 0.25 seconds.

Does it support async database drivers?

Yes. An asyncpg requirement is recognised as Postgres, like psycopg.

Can I run background tasks?

Short tasks that a request starts can finish. But Antideploy runs one web process and an idle app sleeps, so a worker that waits for jobs will not stay alive. Use a scheduled job to call a route on a schedule.

Which Python version is used?

The one you pin in .python-version, runtime.txt or pyproject.toml. If you pin none, the builder chooses one.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.