--- id: taskiq-fastapi version: "0.5.0" license: MIT license_treatment: permissive maintenance: active --- # taskiq-fastapi — FastAPI integration for taskiq License: permissive · Maintenance: active · Downloads: 225.3K/mo ## What it is and what it does taskiq-fastapi bridges FastAPI's dependency injection system with taskiq's distributed task queue. It allows task functions to depend on FastAPI Request objects and access application state (like database pools or configuration) that would normally only be available in HTTP handlers. The library works by injecting a worker-wide Request object at task startup, letting you reuse the same dependency functions across both FastAPI endpoints and taskiq tasks. The package is designed for scenarios where you want to share business logic between synchronous HTTP handlers and asynchronous background tasks without duplicating dependency resolution. It requires explicit use of TaskiqDepends (rather than FastAPI's Depends) in task signatures so the taskiq resolver knows to inject dependencies. The documentation warns that the injected Request is a synthetic object created at worker startup, not tied to any actual HTTP request, and requires careful handling of broker startup/shutdown to avoid infinite recursion. Use it for: - Share a database connection pool or Redis client between FastAPI endpoints and background tasks using the same dependency function. - Inject application configuration or secrets into task functions without passing them as explicit parameters. - Reuse FastAPI middleware-like logic (authentication, logging, tracing) in distributed task workers. - Set up integration tests with InMemoryBroker by manually populating the dependency context for both FastAPI and taskiq. - Build microservices where FastAPI handles HTTP requests and taskiq handles async work, both accessing the same application state. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Integrates FastAPI request and dependency injection into taskiq distributed tasks, allowing task functions to depend on FastAPI Request objects and shared application state. Yes, if you are already using both FastAPI and taskiq and want to share dependency injection logic between them. The low install friction, permissive license, and active maintenance make it a reasonable choice. Be aware it is classified as Alpha, so expect potential API changes. Verify that the synthetic Request object meets your dependency needs before committing to production use. ## Install pip install taskiq-fastapi uv add taskiq-fastapi poetry add taskiq-fastapi ## Installing taskiq-fastapi Before you install: Low install friction with only two runtime dependencies (taskiq and fastapi). Active maintenance as of 2026-04-18. Classified as Alpha, so expect API surface changes. License in practice: MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects. Quickstart: pip install taskiq-fastapi import taskiq_fastapi from taskiq import ZeroMQBroker from fastapi import FastAPI broker = ZeroMQBroker() app = FastAPI() taskiq_fastapi.init(broker, "myapp:app") Requires Python 3.10 or later. Requires a running taskiq broker (e.g., ZeroMQ, Redis) and FastAPI application instance. Verify before relying: - Whether the synthetic Request object created by init() is sufficient for all FastAPI dependency patterns in production workloads. - Performance characteristics when dependency context is large or frequently updated. - Compatibility with FastAPI versions beyond those tested during development. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 225.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags fastapi taskiq integration, fastapi dependency injection tasks, distributed tasks with fastapi, taskiq fastapi request context, async task queue fastapi, fastapi-integration, task-queue, dependency-injection [View on SkillFed](https://skillfed.io/packages/taskiq-fastapi) · [View on PyPI](https://pypi.org/project/taskiq-fastapi/)