Registry / web-framework / taskiq-fastapi

taskiq-fastapi

JSON →
library0.5.0pypypi✓ verified 79d ago

TaskIQ-FastAPI provides integration between FastAPI and TaskIQ, allowing you to run background tasks with access to FastAPI's context (e.g., dependency injection, request state). Current version is 0.5.0, compatible with Python >=3.10. Release cadence is irregular, driven by TaskIQ ecosystem updates.

pip install taskiq-fastapi
INSTALL
IMPORT
SIG · TASKIQ-FASTAPI
T
taskiq-fastapi
web-frameworkpythonv0.5.0
Install
6.9s avg
Import
Disk
43MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 42.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 6.9s · import 0.000s · 44MB
43MB installed
● package 43MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

init
from taskiq_fastapi import init
from taskiq_fastapi import InitFastAPI
initializator
from taskiq_fastapi import initializator
populate_dependency_context
from taskiq_fastapi import populate_dependency_context

Minimal setup integrating TaskIQ with FastAPI using InMemoryBroker. Note: In production, use a persistent broker like Redis or RabbitMQ.

from fastapi import FastAPI from taskiq import TaskIQ from taskiq_fastapi import InitFastAPI, TaskiqFastAPI app = FastAPI() # Initialize TaskIQ broker (e.g., InMemoryBroker) from taskiq import InMemoryBroker broker = InMemoryBroker() # Attach FastAPI integration taskiq_app = TaskiqFastAPI(app, broker) # Register an initialization callback (optional, for context access) @taskiq_app.on_app_init def on_startup(): InitFastAPI().init() @app.get("/") async def root(): return {"message": "Hello World"} # Task must be defined after broker is available @broker.task def my_task(param: str): print(f"Processing {param}") return param
Debug
Known issues
breakingIn version 0.5.0, the import path changed from `taskiq_fastapi.broker` to `taskiq_fastapi` directly. Old imports will break.
fix
Use `from taskiq_fastapi import InitFastAPI, TaskiqFastAPI` instead of `from taskiq_fastapi.broker import ...`.
affects: 0.5.0
gotchaThe `InitFastAPI` must be called during the app lifecycle (usually in a startup event or via `on_app_init` decorator) to inject FastAPI dependencies into tasks. Not calling it results in `RuntimeError: No request context available` when accessing FastAPI dependencies.
fix
Ensure `InitFastAPI().init()` is called at startup (e.g., in a lifespan event or by decorating a function with `@taskiq_app.on_app_init`).
affects: all
gotchaTasks defined before the broker is attached to `TaskiqFastAPI` may not have access to context. Define tasks after calling `taskiq_app = TaskiqFastAPI(app, broker)`.
fix
Define task functions after the `TaskiqFastAPI` instance is created, or ensure the broker is correctly wired before task definitions.
affects: all
deprecatedThe `TaskiqFastAPI` class previously accepted a `middleware` argument; this is deprecated in favor of using `ResultBackendMiddleware` separately.
fix
Remove `middleware` parameter from `TaskiqFastAPI` and add `ResultBackendMiddleware` to the app if needed.
affects: >=0.4.0
Upgrade
Version history
0.5.0latest on PyPI · released Apr 18, 2026
Audit
Dependencies
taskiqrequiredCore dependency; taskiq-fastapi is an integration layer on top of TaskIQ.
fastapirequiredRequired to use the integration with FastAPI applications.
Agent activity
49 hits · last 30 days
node
44
OpenAI (training)
1
Resources
taskiq-fastapi — pip install taskiq-fastapi · libregistry