HyperTune SDK

raw JSON →
0.6.5 verified Fri May 01 auth: no python

A Python SDK for HyperTune, a feature flag and experimentation platform. Current version 0.6.5 with weekly releases. Requires Python ≥3.9 and <4.0.

pip install hypertune-sdk
error ModuleNotFoundError: No module named 'hypertune_sdk'
cause Incorrect import path. Package name is 'hypertune-sdk' on PyPI, but import module is 'hypertune'.
fix
Install the package: pip install hypertune-sdk, then import: from hypertune import HyperTune.
error hypertune.exceptions.HyperTuneError: 401 Unauthorized
cause Missing or invalid API token.
fix
Set the environment variable HYPERTUNE_API_TOKEN or pass api_token to HyperTune constructor.
gotcha The import module is 'hypertune', not 'hypertune_sdk'. The PyPI package name is 'hypertune-sdk'.
fix Use 'from hypertune import HyperTune' instead of 'from hypertune_sdk import HyperTune'.
deprecated The 'get_flag' method may be deprecated in future versions for a more explicit API. Check docs.
fix Use 'client.evaluate_flag("flag-name", context)' if available.
gotcha API token must be passed or set via environment variable HYPERTUNE_API_TOKEN; otherwise, requests fail with 401.
fix Set the environment variable or pass api_token as constructor argument.

Initialize the client with an API token and environment, then evaluate a feature flag.

import os
from hypertune import HyperTune

client = HyperTune(
    api_token=os.environ.get("HYPERTUNE_API_TOKEN", ""),
    environment="production",
)
flag_value = client.get_flag("my-flag", {"user": {"id": "42"}})
print(flag_value)