Experimentation Lab
Interactive implementation reference
Feature SDK implementation

Python

Origin-side flag decisions for Django, Flask, FastAPI, workers, and data services.

Python server
This runtime cannot execute inside a Next.js browser process. The page shows the native, official SDK shape; use the JavaScript, React, or Next.js pages for a live decision and event round trip with the same project, flag, event, and visitor ID.

Implementation

Official docs ↗
pip install optimizely-sdk
from optimizely import optimizely

client = optimizely.Optimizely(sdk_key=SDK_KEY)
user = client.create_user_context('visitor-123', {'plan': 'pro'})
decision = user.decide('demo_flag')
user.track_event('demo_purchase', {'revenue': 9900})