NEWLoisaX CLI 1.4 and 1-command cloud deploys now liveRead post

How to host a high-performance Python API with FastAPI and Uvicorn

FastAPI pairs modern Python type hints with async speed. Deploy a production-ready Uvicorn service in minutes.

Updated Nov 10, 2026·10 min read·2 steps

What you will learn:

  • Estruturar uma API assíncrona em Python utilizando FastAPI e Pydantic.
  • Declarar fastapi, uvicorn[standard] e pydantic no requirements.txt.
  • Configurar o comando Uvicorn escutando em 0.0.0.0 na porta dinâmica.
  • Controlar a exposição da documentação interativa (/docs) em produção.
  • Proteger chaves de banco de dados e integrações de IA em variáveis.
  • Publicar na LoisaX e monitorar a rota de saúde GET /health.

Download ready FastAPI starter

Includes requirements.txt and main.py with /health and Pydantic validation.

Step 01

Define requirements.txt and main.py

Pin fastapi, uvicorn[standard], and pydantic at the project root:

1fastapi==0.115.6
2uvicorn[standard]==0.34.0
3pydantic==2.10.4

Step 02

Run Uvicorn on 0.0.0.0 and dynamic PORT

Start with uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000} --proxy-headers.

Step 03

Got an error? The most common ones, with the fix

Could not import module "main"

Cause: Entry file name does not match main:app.

Fix: Match <filename>:<app_variable> in your start command.

Step 04

Frequently asked questions

1–2 async workers are ideal up to 1 vCPU without duplicating RAM footprint.

Community & Education

Our commitment to developers

At LoisaX, we believe our role goes beyond providing hosting and cloud computing services. We also want to contribute to the learning and growth of our developer community.

We are continuously expanding our catalog of guides with new content on programming languages, API integrations, automation, and application development.

More deployment guides

All guides