Skip to main content

OpenFeature Providers

OpenFeature is a CNCF-incubating open standard for feature flagging. GrowthBook provides OpenFeature provider SDKs for Python, Go, .NET, and Java — listed in the OpenFeature ecosystem.

Prerequisites

  • A GrowthBook account (cloud or self-hosted)
  • An SDK Connection key — create one under Settings → SDK Connections in the GrowthBook UI
  • The API host:
    • Cloud: https://cdn.growthbook.io
    • Self-hosted: your own GrowthBook URL (e.g. https://growthbook.example.com)

Why Use OpenFeature with GrowthBook?

OpenFeature defines a vendor-neutral interface for evaluating feature flags. Using a GrowthBook OpenFeature provider means:

  • Vendor portability — Your flag evaluation code is identical regardless of which provider is active. Switching from or to GrowthBook only requires changing the provider bootstrap, not a single flag call.
  • Standardized API — Teams use the same OpenFeature interface they already know across all services.
  • Ecosystem compatibility — OpenFeature-aware tooling — including OpenTelemetry hooks and other instrumentation — works automatically with GrowthBook.
  • Polyglot consistency — The same conceptual API spans Python, Go, .NET, Java (and more), giving teams a single mental model.
When to use the native GrowthBook SDK instead

The native GrowthBook SDKs expose features that go beyond the OpenFeature interface: Sticky Bucketing, Visual Editor experiments, inline experiment definitions, and real-time SSE streaming. If you need those capabilities, use the native SDK for your language instead.

Installation & Setup

GitHub: growthbook-openfeature-provider-python  |  PyPI: growthbook-openfeature-provider

Requirements: Python 3.9+

pip install growthbook-openfeature-provider

Async setup (recommended for async frameworks like FastAPI, aiohttp):

import asyncio
from openfeature.api import OpenFeatureAPI
from openfeature.evaluation_context import EvaluationContext
from growthbook_openfeature_provider import GrowthBookProvider, GrowthBookProviderOptions

async def main():
provider = GrowthBookProvider(GrowthBookProviderOptions(
api_host="https://cdn.growthbook.io",
client_key="sdk-abc123"
))
await provider.initialize()
OpenFeatureAPI.set_provider(provider)

client = OpenFeatureAPI.get_client("my-app")
# ... evaluate flags ...

await provider.close()

asyncio.run(main())

Synchronous setup:

from openfeature.api import OpenFeatureAPI
from growthbook_openfeature_provider import GrowthBookProvider, GrowthBookProviderOptions

provider = GrowthBookProvider(GrowthBookProviderOptions(
api_host="https://cdn.growthbook.io",
client_key="sdk-abc123"
))
provider.initialize_sync()
OpenFeatureAPI.set_provider(provider)

client = OpenFeatureAPI.get_client("my-app")

Evaluation Context (Targeting Attributes)

Pass user attributes to the OpenFeature client via an EvaluationContext. These become GrowthBook targeting attributes used for percentage rollouts, feature targeting rules, and experiment bucketing.

The targetingKey maps to the user ID in GrowthBook. Additional attributes (e.g. country, plan, email) are matched against your feature flag targeting conditions.

from openfeature.evaluation_context import EvaluationContext

context = EvaluationContext(
targeting_key="user-123",
attributes={
"country": "US",
"plan": "premium",
"email": "user@example.com",
}
)

Evaluating Feature Flags

OpenFeature defines five value types. GrowthBook's feature flags map to all of them.

Boolean

The most common type — use for on/off feature gates.

# Synchronous
enabled = client.get_boolean_value("dark-mode", False, context)

# Async (returns FlagEvaluationDetails with value, reason, variant, etc.)
details = await provider.resolve_boolean_details_async("dark-mode", False, context)
enabled = details.value

String

Use for multi-variant flags where the value is a string (e.g. button color, layout variant).

variant = client.get_string_value("button-color", "blue", context)

Integer & Float/Double

Use for numeric feature values such as rate limits, timeouts, or pricing.

request_limit = client.get_integer_value("api-request-limit", 100, context)
price = client.get_float_value("subscription-price", 9.99, context)

Object

Use for structured feature values (e.g. configuration payloads, theme objects).

config = client.get_object_value("theme-config", {"color": "blue"}, context)

Configuration Options

OptionPythonGo.NETJavaDescription
api_host / apiHostGrowthBook CDN or self-hosted URL
client_key / clientKeySDK Connection key from GrowthBook
decryption_keyKey for encrypted SDK endpoint payloads
cache_ttlSeconds before re-fetching features (default: 60)
enabledEnable/disable the provider entirely
qa_modeForces all experiments into the control variation

Shutdown & Cleanup

Always shut down the provider when your application exits to close background connections.

await provider.close()       # async
# or
provider.close_sync() # sync

Further Reading