Quickstart by stack
Python Quickstart
Install the Python SDK with pip, evaluate a flag with context in Django or Flask, and add async support for FastAPI in one pass.
Prerequisites
- Python 3.8 or later.
- A server key stored in environment configuration and not committed to source.
- A flag key you can test in a non-production environment.
pip install zenmanage
from zenmanage import Zenmanage, ConfigBuilder
from zenmanage.flags.context import Context, Attribute
import os
zenmanage = Zenmanage(
ConfigBuilder.create()
.with_environment_token(os.environ['ZENMANAGE_SERVER_KEY'])
.build()
)
context = Context(
type='user',
name='Jane Doe',
identifier='usr_123',
attributes=[Attribute('plan', ['enterprise'])]
)
flag = zenmanage.flags().with_context(context).single('new-checkout', False)
if flag.is_enabled():
# render new experience
pass
from contextlib import asynccontextmanager
from fastapi import FastAPI, Request
from zenmanage import Zenmanage, ConfigBuilder
from zenmanage.flags.context import Context
import os
zenmanage = Zenmanage(
ConfigBuilder.create()
.with_environment_token(os.environ['ZENMANAGE_SERVER_KEY'])
.build()
)
@asynccontextmanager
async def lifespan(app: FastAPI):
await zenmanage.start()
yield
await zenmanage.close()
app = FastAPI(lifespan=lifespan)
@app.get('/checkout')
async def checkout(request: Request):
user = request.state.user
context = Context.single('user', user.id, user.name)
flag = await zenmanage.flags().with_context(context).single_async('new-checkout', False)
return {'new_checkout': flag.is_enabled()}
try:
timeout = zenmanage.flags().single('api-timeout-ms', 5000).as_number()
except Exception:
timeout = 5000
Sync and async clients
The Python SDK ships both a sync client for Django and Flask and a fully async client for FastAPI and other ASGI frameworks. Both share the same context model and evaluation behavior, so you can use either without changing your flag logic.
Context and defaults
Pass a stable identifier in every context so rollout bucketing is deterministic. Always provide an inline default to single() so the application behaves safely if the SDK cannot reach the evaluation layer.
Next step
Take the next integration step in your own stack.
Start with the quickstart that matches your runtime, then return to the reference pages when you need exact request and payload details.
Language and framework names and logos shown above are trademarks or registered trademarks of their respective owners. Their use here is for identification purposes only and does not imply endorsement of, or affiliation with, Zenmanage.