Docs Set up your stack
Set up Relia in a Python app
Add Relia to a FastAPI, Django or Flask app with one command, so its requests, errors and database calls show up in Relia.
This page sets Relia up by hand from a terminal. To have your AI assistant do it instead, see Set up Relia with your AI assistant.
Before you start
- A Relia account (Create your account).
- Python 3.9 or newer.
- A terminal open in your app's folder, with your app's virtual environment active.
Steps
Install the package and run the setup:
pip install relia-sdk relia initpython -m reliaruns the same setup if thereliacommand isn't on your path.Sign in. Choose the browser option, copy the token from the CLI Authentication page, and paste it back into the terminal.
Choose what to monitor: API & Request APM (FastAPI / Flask / Django).
Pick your Relia project, or create one right there. Then pick a service, or create one. The service is the name your app shows under in Relia.
Check what it wrote:
- Your
.envgetsRELIA_PROJECT_ID,RELIA_KEY,RELIA_SERVICE_NAMEandRELIA_OTLP_ENDPOINT. - A new file,
relia_tracing.py, starts Relia. - FastAPI: your entry file (for example
main.py) gets two lines at the top that start Relia, and one line right afterapp = FastAPI(...). - Flask:
ReliaFlask(app)is added after your app is created. - Django:
relia.integrations.django.ReliaDjangoMiddlewaregoes first inMIDDLEWARE, insettings.py.
- Your
Answer "Tell Relia who your users are?" Say yes if your app has sign-in. The setup prints the line to add; see Identify your users.
Tip: watch See which customers a bug hit: identify users in Relia (2 min).
Start your app (for example with
uvicorn) and call one of its endpoints.
Tip: for the framework's own request tracing, install the matching extra:
pip install "relia-sdk[fastapi]","relia-sdk[flask]"or"relia-sdk[django]".
Set it up by hand instead
At the very top of your entry module, before your framework is imported:
import relia
relia.start(project_id="<your project id>", service_name="my-api")
Then, depending on your framework:
# FastAPI: after app = FastAPI()
from relia.integrations.fastapi import instrument_fastapi
instrument_fastapi(app, project_id="<your project id>", service_name="my-api")
# Flask: after app = Flask(__name__)
from relia.integrations.flask import ReliaFlask
ReliaFlask(app)
For Django, add "relia.integrations.django.ReliaDjangoMiddleware" first in MIDDLEWARE. Put your project key in the server's environment as RELIA_KEY. Your project's id and key are on your project page under Setup Guide & SDK.
What Relia records
- Every request with its route template (
/orders/{id}, never one row per id), status and time. - Errors with their stack traces.
- Outgoing calls made with
requests,httpxandaiohttp. - Database calls (PostgreSQL, MySQL, MongoDB, Redis, SQLAlchemy), with values removed.
- Celery tasks and AWS calls.
- Log records at WARNING and above.
RELIA_LOG_LEVELchanges the level;RELIA_LOGS=0turns logs off. - Calls to AI models in your product. See Monitor AI calls in your app.
Settings
| Variable | What it does | Default |
|---|---|---|
RELIA_PROJECT_ID |
Your project id | none |
RELIA_KEY |
Your project key | none |
RELIA_SERVICE_NAME |
The name your app shows under in Relia | backend |
RELIA_ENV |
Environment label | production |
On your laptop, set RELIA_ENV=development so test traffic stays apart from production.
When you deploy
Copy the RELIA_* lines from .env into your host's environment variables (Render, Railway, Fly, a Dockerfile and so on).
Check it worked
Open your project in Relia and go to the Setup tab. Requests from your server changes from Not yet to Arriving, usually within a minute. Your requests and errors appear under APIs, and your queries under Database.
If something's wrong
- Still "Not yet" after a few minutes: make sure Relia starts before your framework is imported (the lines must be at the very top of the entry file), restart and call an endpoint again. Then see Relia shows no data.
- The setup couldn't patch your entry file: it prints the lines to add. Add them by hand as shown above.
- Django middleware missing: the setup looks for
settings.pyin common places. If yours is elsewhere, add the middleware line yourself.
Next
Last checked against the product: 1 Nov 2026