Skip to main content

flagd Provider for OpenFeature

This provider is designed to use flagd's evaluation protocol, or locally evaluate flags defined in a flagd flag definition via the OpenFeature Python SDK.

Installation

pip install openfeature-provider-flagd

Configuration and Usage

The flagd provider can operate in two modes: RPC (evaluation takes place in flagd, via gRPC calls) or in-process (evaluation takes place in-process, with the provider getting a ruleset from a compliant sync-source).

Remote resolver (RPC)

This is the default mode of operation of the provider. In this mode, FlagdProvider communicates with flagd via the gRPC protocol. Flag evaluations take place remotely at the connected flagd instance.

Instantiate a new FlagdProvider instance and configure the OpenFeature SDK to use it:

from openfeature import api
from openfeature.contrib.provider.flagd import FlagdProvider

api.set_provider(FlagdProvider())

In-process resolver

This mode performs flag evaluations locally (in-process). Flag configurations for evaluation are obtained via gRPC protocol using sync protobuf schema service definition.

Consider the following example to create a FlagdProvider with in-process evaluations,

from openfeature import api
from openfeature.contrib.provider.flagd import FlagdProvider
from openfeature.contrib.provider.flagd.config import ResolverType

api.set_provider(
    FlagdProvider(
        resolver_type=ResolverType.IN_PROCESS,
    )
)

In the above example, in-process handlers attempt to connect to a sync service on address localhost:8013 to obtain flag definitions.

File mode

In-process resolvers can also work in an offline mode. To enable this mode, you should provide a valid flag configuration file with the option offlineFlagSourcePath.

from openfeature import api
from openfeature.contrib.provider.flagd import FlagdProvider
from openfeature.contrib.provider.flagd.config import ResolverType

api.set_provider(
    FlagdProvider(
        resolver_type=ResolverType.FILE,
        offline_flag_source_path="my-flag.json",
    )
)

Provider will attempt to detect file changes using polling. Polling happens at 5 second intervals and this is currently unconfigurable. This mode is useful for local development, tests and offline applications.

Configuration options

The default options can be defined in the FlagdProvider constructor.

Option name Environment variable name Type & Values Default Compatible resolver
resolver_type FLAGD_RESOLVER enum - rpc, in-process rpc
host FLAGD_HOST str localhost rpc & in-process
port FLAGD_SYNC_PORT (in-process), FLAGD_PORT (rpc or fallback) int 8013 (rpc), 8015 (in-process) rpc & in-process
tls FLAGD_TLS bool false rpc & in-process
cert_path FLAGD_SERVER_CERT_PATH String null rpc & in-process
deadline FLAGD_DEADLINE_MS int 500 rpc & in-process
stream_deadline_ms FLAGD_STREAM_DEADLINE_MS int 600000 rpc & in-process
keep_alive_time FLAGD_KEEP_ALIVE_TIME_MS int 0 rpc & in-process
selector FLAGD_SOURCE_SELECTOR str null in-process
cache_type FLAGD_CACHE enum - lru, disabled lru rpc
max_cache_size FLAGD_MAX_CACHE_SIZE int 1000 rpc
retry_backoff_ms FLAGD_RETRY_BACKOFF_MS int 1000 rpc
offline_flag_source_path FLAGD_OFFLINE_FLAG_SOURCE_PATH str null in-process
channel_credentials - grpc.ChannelCredentials null rpc & in-process

Custom channel credentials

Pass custom grpc.ChannelCredentials to channel_credentials to control the TLS setup. The provider uses these credentials in both resolver modes. They take precedence over tls and cert_path, and the provider creates a secure channel even when tls is False.

To trust a private server certificate authority (CA), supply only the root certificates:

import grpc

from openfeature.contrib.provider.flagd import FlagdProvider

with open("ca.pem", "rb") as ca_file:
    credentials = grpc.ssl_channel_credentials(root_certificates=ca_file.read())

provider = FlagdProvider(channel_credentials=credentials)

When flagd requires mutual TLS (mTLS), also supply the client key and certificate:

import grpc

from openfeature.contrib.provider.flagd import FlagdProvider

with (
    open("ca.pem", "rb") as ca_file,
    open("client-key.pem", "rb") as key_file,
    open("client-cert.pem", "rb") as cert_file,
):
    credentials = grpc.ssl_channel_credentials(
        root_certificates=ca_file.read(),
        private_key=key_file.read(),
        certificate_chain=cert_file.read(),
    )

provider = FlagdProvider(channel_credentials=credentials)

Selector Handling (In-Process Mode Only)

Current Implementation

As of this SDK version, the selector parameter is passed via both gRPC metadata headers (flagd-selector) and the request body when using in-process mode. This dual approach ensures maximum compatibility with all flagd versions.

Configuration Example:

from openfeature import api
from openfeature.contrib.provider.flagd import FlagdProvider
from openfeature.contrib.provider.flagd.config import ResolverType

api.set_provider(
    FlagdProvider(
        resolver_type=ResolverType.IN_PROCESS,
        selector="my-flag-source",  # Passed via both header and request body
    )
)

The selector is automatically passed via:

  • gRPC metadata header (flagd-selector) - For flagd v0.11.0+ selector normalization
  • Request body - For backward compatibility with older flagd versions

Backward Compatibility

This dual transmission approach ensures the Python SDK works seamlessly with all flagd service versions:

  • Older flagd versions read the selector from the request body
  • Newer flagd versions (v0.11.0+) prefer the selector from the gRPC metadata header
  • Both approaches are supported simultaneously for maximum compatibility

Related Resources:

  • Upstream issue: open-feature/flagd#1814
  • Selector normalization affects in-process evaluations that filter flag configurations by source

Reconnection

Reconnection is supported by the underlying gRPC connections. If the connection to flagd is lost, it will reconnect automatically. A failure to connect will result in an error event from the provider, though it will attempt to reconnect indefinitely.

Deadlines

Deadlines are used to define how long the provider waits to complete initialization or flag evaluations. They behave differently based on the resolver type.

Deadlines with Remote resolver (RPC)

If the remote evaluation call is not completed within this deadline, the gRPC call is terminated with the error DEADLINE_EXCEEDED and the evaluation will default.

TLS

TLS is available in situations where flagd is running on another host.

You may optionally supply an X.509 certificate in PEM format. Otherwise, the default certificate store will be used.

from openfeature import api
from openfeature.contrib.provider.flagd import FlagdProvider

api.set_provider(
    FlagdProvider(
        tls=True,  # use TLS
        cert_path="etc/cert/ca.crt",  # PEM cert
    )
)

License

Apache 2.0 - See LICENSE for more information.

Metadata

Release files for openfeature-provider-flagd 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openfeature-provider-flagd 0.6.1
File Size Uploaded Provenance
openfeature_provider_flagd-0.6.1.tar.gz 73.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for openfeature-provider-flagd 0.6.1
File Interpreter ABI Platform
openfeature_provider_flagd-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 138.1 kB

Release files / openfeature_provider_flagd-0.6.1.tar.gz

Download URL openfeature_provider_flagd-0.6.1.tar.gz
Size 73.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f6a3f9b9873923f0ba8cae10248f3503e1f6929b5b60909f54677cdb8868f4b8
BLAKE2b-256 checksum
How to use checksums
352fdf44deb9bce7121e5a2951054c6a48fd71b72981806d8d20e485c8622dde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / openfeature_provider_flagd-0.6.1-py3-none-any.whl

Download URL openfeature_provider_flagd-0.6.1-py3-none-any.whl
Size 64.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51abf745af31fccc2029d093f87f5769af488c2634794cee935fc3594add8d52
BLAKE2b-256 checksum
How to use checksums
8ea24cb745c2561a7db18043ae020f719216aa38e07528e70d6436468efb64a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for openfeature-provider-flagd 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for openfeature_provider_flagd-0.6.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page