LaunchDarkly OpenFeature Provider for Python Server SDK
raw JSON → 0.5.1 verified Mon Apr 27 auth: no python
An OpenFeature provider that bridges the LaunchDarkly Python server SDK with the OpenFeature API, enabling feature flag evaluation through the standard OpenFeature interface. Current version 0.5.1, requires Python <4.0,>=3.9. Pre-1.0 release with active development.
pip install launchdarkly-openfeature-server Common errors
error ModuleNotFoundError: No module named 'launchdarkly_openfeature' ↓
cause Installed wrong package or missing dependency.
fix
Install via: pip install launchdarkly-openfeature-server
error ImportError: cannot import name 'LaunchDarklyProvider' from 'launchdarkly_openfeature' ↓
cause Importing from wrong submodule.
fix
Use: from launchdarkly_openfeature.server import LaunchDarklyProvider
error AttributeError: 'NoneType' object has no attribute 'get_boolean_value' ↓
cause OpenFeature client not properly initialized or provider not set.
fix
Ensure api.set_provider() is called before api.get_client().
Warnings
breaking The provider requires an initialized LDClient instance. Do not use ldclient.set_sdk_key() global initialization; the provider expects an explicit client. ↓
fix Instantiate LDClient with config and pass it to LaunchDarklyProvider.
gotcha The library is pre-1.0 (0.x.y). APIs may change without major version bump. Pin to exact version in production. ↓
fix Pin exact version in requirements: launchdarkly-openfeature-server==0.5.1
deprecated Do not use ldclient.get() global client. The provider expects an explicit LDClient instance. ↓
fix Create explicit LDClient and pass to provider.
Imports
- LaunchDarklyProvider wrong
from launchdarkly_openfeature import LaunchDarklyProvidercorrectfrom launchdarkly_openfeature.server import LaunchDarklyProvider
Quickstart
import os
from ldclient import Config, LDClient
from openfeature import api
from openfeature.evaluation_context import EvaluationContext
from launchdarkly_openfeature.server import LaunchDarklyProvider
# Initialize LD client
ld_config = Config(os.environ.get('LAUNCHDARKLY_SDK_KEY', ''))
ld_client = LDClient(config=ld_config)
# Set provider in OpenFeature
api.set_provider(LaunchDarklyProvider(ld_client))
# Get OpenFeature client
client = api.get_client()
# Evaluate a flag
targeting_key = 'user-key'
ctx = EvaluationContext(targeting_key=targeting_key, attributes={'email': 'user@example.com'})
result = client.get_boolean_value('my-flag', default_value=False, evaluation_context=ctx)
print(f'Flag value: {result}')