Python
Verified against provider 0.3.0 and SDK 0.10.0.
Install
Section titled “Install”pip install openfeature-provider-ofrepRead a flag
Section titled “Read a flag”from openfeature import apifrom openfeature.contrib.provider.ofrep import OFREPProviderfrom openfeature.evaluation_context import EvaluationContext
api.set_provider( OFREPProvider( "https://flags.example.com", headers_factory=lambda: {"x-api-key": "your-read-api-key"}, ))
client = api.get_client()ctx = EvaluationContext(targeting_key="user-123", attributes={"plan": "pro"})
if client.get_boolean_value("new-checkout", False, ctx): ... # serve the new checkoutheaders_factory is called per request, so the x-api-key header is attached to every evaluation.
A wrong key returns the default you passed rather than the real value.