FastAPI
v1.6.8 Apache-2.0z4j-fastapi ยท Upstream project
Lifespan-hook integration for async stacks.
FastAPI lifespan-aware. Most commonly paired with arq or taskiq (both async-native) but works with Celery or RQ when your sync stack calls for them. Dependency-injection friendly.
- Latest
- v1.6.8
- Released
- 2026-06-08
- License
- Apache-2.0
Install
pip install z4j-fastapi FastAPI + any task engine
Every extra pulls the engine adapter AND its companion scheduler in one shot, so a fresh install never needs a second command.
| Engine | Install command | Bundled scheduler |
|---|---|---|
| Celery |
pip install z4j-fastapi[celery]
| celery-beat |
| RQ |
pip install z4j-fastapi[rq]
| rq-scheduler |
| Dramatiq |
pip install z4j-fastapi[dramatiq]
| APScheduler |
| Huey |
pip install z4j-fastapi[huey]
| huey-periodic |
| arq recommended |
pip install z4j-fastapi[arq]
| arq-cron |
| TaskIQ |
pip install z4j-fastapi[taskiq]
| taskiq-scheduler |
| Every engine (CI / kitchen sink) |
pip install z4j-fastapi[all]
| all of the above |
pip install z4j-fastapi
with no extra installs only the framework adapter. Pick an engine extra
for the normal case.
Wire it in
from fastapi import FastAPI
from z4j_fastapi import install
app = FastAPI(lifespan=install) Confirm the agent reaches the brain
Run the doctor as the same user the service runs under. It probes brain DNS / TCP / TLS / WebSocket upgrade, the on-disk buffer path, and reports auto-detected engines - exits 0 on all-green, 1 on any failure.
python -m z4j_fastapi doctor
Catches the gunicorn-under-www-data silent startup failure (the agent now auto-relocates the buffer to $TMPDIR/z4j-{uid} when $HOME is unwritable), NAT / firewall / cert mismatches, and wrong-token / wrong-project_id problems with a specific failure reason. Add --no-websocket to skip the WS round-trip, --json for scripts. Reference.
FastAPI-specific features
FastAPI works with every z4j engine
The framework adapter handles lifecycle and config. Any engine adapter slots in alongside.
Celery
The industry standard, covered end-to-end.
Learn more
RQ
Lightweight Redis queue, fully instrumented.
Learn more
Dramatiq
Middleware-driven Dramatiq observability.
Learn more
Huey
Lightweight Redis/SQLite queue, first-class.
Learn more
arq
Async Redis queue for FastAPI-era Python.
Learn more
taskiq
Broker-agnostic async task framework.
Learn more