LoggerAI for Python
Performance monitoring, errors, logs and health checks for FastAPI, Starlette, Django, Flask and Celery, with AI that explains what went wrong.
- Every endpoint timed under its route template (
/orders/{order_id}): p50/p95/p99, Apdex, status codes, slow and failed requests. - What each request waits on: database queries (SQLAlchemy and Django),
outgoing HTTP (
httpx,requests), Redis. - Exceptions, grouped by cause, with stack traces that show your code first.
- Logs at warning and above.
- Health checks you define (database, cache, a queue).
- Background work (Celery tasks, scripts) timed like requests.
- Browser sessions recorded by LoggerAI's browser script link to the
server request each click caused (
traceparent,x-loggerai-session).
The package is loggerai-sdk; you import it as loggerai.
Secrets (passwords, tokens, cookies, API keys, JWTs) are masked before anything leaves your server, request and response bodies are never sent, and users are counted by a one-way hash of their id. No dependencies; Python 3.8+.
Install
pip install loggerai-sdk
Get your project's secret key (sk_live_...) from LoggerAI → your
project → Connect, and set it in the environment:
LOGGERAI_KEY=sk_live_...
LOGGERAI_RELEASE=$GIT_SHA # optional: "since release X"
Without a key nothing is recorded or sent, so local development stays quiet.
Check it can reach LoggerAI from your server (or container):
python -m loggerai test
FastAPI / Starlette
import loggerai
from loggerai.asgi import LoggerAIMiddleware
loggerai.init()
app = FastAPI()
app.add_middleware(LoggerAIMiddleware)
Django
# settings.py
import loggerai
loggerai.init()
MIDDLEWARE = [
"loggerai.django.LoggerAIMiddleware", # first
...
]
Flask
import loggerai, loggerai.flask
loggerai.init()
app = Flask(__name__)
loggerai.flask.instrument(app)
Celery
import loggerai, loggerai.celery
loggerai.init(service="worker")
loggerai.celery.instrument()
Any other WSGI app
from loggerai.wsgi import LoggerAIMiddleware
application = LoggerAIMiddleware(application)
Health checks
def database():
with engine.connect() as c:
c.execute(text("SELECT 1"))
return True # or (False, "why")
loggerai.init(health_checks={"database": database, "redis": lambda: r.ping()})
They run every minute in the background and show on the project's health page; alert on them from the dashboard.
Server CPU and memory
The SDK also sends the server's CPU, memory, swap and disk every 30
seconds, so LoggerAI can tell when the server itself is why the app got slow
("CPU on web-1 hit 97%"). Inside Docker or Kubernetes it reports the
container's own CPU and memory limits. It reads Linux's /proc; install
psutil for macOS and Windows. Turn it off with LOGGERAI_HOST_METRICS=false.
More
loggerai.set_user(request.user.id) # only a one-way hash is sent
with loggerai.measure("api.stripe.com", "POST"): # calls it can't see itself
stripe.PaymentIntent.confirm(intent_id)
with loggerai.track("job", "send_invoices"): # scripts, cron jobs
send_invoices()
try:
risky()
except ValueError as e:
loggerai.capture_exception(e, order=order.id) # handled, but worth seeing
loggerai.flush() # at the end of a short script or a serverless call
Settings
| Environment | init() |
Default | |
|---|---|---|---|
LOGGERAI_KEY |
key |
— | Secret key; off without it |
LOGGERAI_SERVICE |
service |
app |
Name this process (api, worker) |
LOGGERAI_ENVIRONMENT |
environment |
production |
Separates production from staging |
LOGGERAI_RELEASE |
release |
— | Version or git SHA |
LOGGERAI_ENABLED |
enabled |
true |
Turn it off without removing the key |
logs_level |
"WARNING" |
Lowest log level sent; None for no logs |
|
ignore_paths |
/health, /up, … |
Paths not recorded | |
capture_queries, capture_http, capture_redis |
True |
||
flush_interval |
5 |
Seconds between batches | |
LOGGERAI_HOST_METRICS |
host_metrics |
True |
The server's CPU, memory and disk |
How it sends
Records are kept in memory and sent from a background thread every few seconds, gzipped, with a 2-second timeout. Requests never wait on LoggerAI. If it can't be reached, records are dropped instead of piling up. With gunicorn or uWSGI, each worker process sends its own batches.
Support
Metadata
Release files for loggerai-sdk 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| loggerai_sdk-0.2.0.tar.gz | 22.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| loggerai_sdk-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.8 kB
Release files / loggerai_sdk-0.2.0.tar.gz
| Download URL | loggerai_sdk-0.2.0.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00a352fc63766455d548a22e9b5e32d6842c2f4b79cc351ce0318398dd71eef0
|
|
BLAKE2b-256 checksum How to use checksums |
bdcfbea6db4b974e150a202e4a4eacf652e04d89ace4d882a26ae7c56ae0cf00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency logRelease files / loggerai_sdk-0.2.0-py3-none-any.whl
| Download URL | loggerai_sdk-0.2.0-py3-none-any.whl |
|---|---|
| Size | 24.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2678cf0993e1c49ea2a26a3a1713de89735066fbf32d88163cd0edf92b62baa9
|
|
BLAKE2b-256 checksum How to use checksums |
d1d5b0dccd1fed655291353c3a88a0dbf8d6c59fac45dd39776ddd02d509c9d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.
Transparency log