Production-ready feature flags for Litestar applications.
uv add litestar-flags
# With extras
uv add litestar-flags[redis] # Redis backend
uv add litestar-flags[database] # SQLAlchemy backend
uv add litestar-flags[workflows] # Approval workflows
uv add litestar-flags[openfeature] # OpenFeature SDK provider
uv add litestar-flags[prometheus] # Prometheus metrics
uv add litestar-flags[observability] # OpenTelemetry + structlog
uv add litestar-flags[all] # Everythingfrom litestar import Litestar, get
from litestar_flags import FeatureFlagsPlugin, FeatureFlagsConfig, FeatureFlagClient
config = FeatureFlagsConfig()
plugin = FeatureFlagsPlugin(config=config)
@get("/")
async def index(feature_flags: FeatureFlagClient) -> dict:
if await feature_flags.is_enabled("new_checkout"):
return {"flow": "new"}
return {"flow": "legacy"}
app = Litestar(plugins=[plugin])- Multiple backends - Memory, Redis, and SQLAlchemy storage
- Percentage rollouts - Gradual releases with consistent hashing
- User targeting - Rules based on user attributes
- Segment-based targeting - Reusable user groups for complex targeting
- A/B testing - Weighted variants for experiments
- Time-based rules - Scheduled launches and maintenance windows
- Multi-environment - Environment inheritance, promotion, and per-env configs
- Admin API - REST endpoints for flag management with RBAC and audit logging
- Analytics - Evaluation tracking, metrics, and Prometheus export
- OpenFeature support - Vendor-agnostic evaluation via OpenFeature SDK
- Approval workflows - Human-in-the-loop governance for enterprise use
Full docs at flags.litestar.scriptr.dev.
git clone https://github.com/JacobCoffee/litestar-flags.git
cd litestar-flags
uv sync --all-extras
uv run pytestMIT