Prefab Cloud Python
raw JSON → 0.12.1 verified Sat May 09 auth: no python
Official Python client for Prefab, a feature flags, dynamic log levels, and configuration-as-a-service platform. Supports context-aware evaluations, SSE streaming, and cloud-based configuration management. Current version: 0.12.1, requires Python >=3.9, <4. Release cadence: monthly.
pip install prefab-cloud-python Common errors
error ImportError: cannot import name 'Client' from 'prefab_cloud_python' ↓
cause The package is installed as 'prefab-cloud-python' but the import module is 'prefab'.
fix
Use 'from prefab import Client' instead of 'from prefab_cloud_python import Client'.
error TypeError: check() missing 1 required positional argument: 'context' ↓
cause The 'context' parameter became mandatory in v0.12.0.
fix
Pass a Context object: client.check('flag-key', Context(user_key='...'))
Warnings
breaking The import path changed from 'import prefab_cloud_python' to 'from prefab import Client/Prefab' in version 0.11.0. ↓
fix Replace 'import prefab_cloud_python' with 'from prefab import Prefab' and update usage accordingly.
gotcha Context must be passed to most flag evaluations; omitting it may lead to incorrect results. ↓
fix Always create a Context with at least a user_key and pass it to client.check().
deprecated The 'PrefabConfig' object is deprecated in favor of 'Prefab' and 'Client'. ↓
fix Use 'Prefab' class with api_key parameter directly.
Imports
- Client wrong
from prefab_cloud_python import Clientcorrectfrom prefab import Client - Prefab wrong
import Prefabcorrectfrom prefab import Prefab - Context
from prefab import Context
Quickstart
import os
from prefab import Prefab, Context
client = Prefab(api_key=os.environ.get('PREFAB_API_KEY', ''))
context = Context(user_key="user-123", attributes={"plan": "premium"})
flag = client.check("my-feature-flag", context)
print("Flag enabled:", flag)