Skip to content

Configuration

The SDK is designed to work optimally out of the box with minimal configuration. Only your API key is required.

Basic Configuration

from featsync import Featsync
client = Featsync(api_key="fs_your_api_key")

That’s it! The SDK automatically:

  • Caches flags for 5 minutes
  • Prefetches all flags on initialization
  • Uses a 5-second request timeout
  • Falls back to stale cache on API errors

Full Configuration

client = Featsync(
# Required: Your API key from the dashboard
api_key="fs_your_api_key",
# Optional: Environment to evaluate (default: 'production')
environment="production",
# Optional: Override base URL (for development/testing)
base_url="https://custom.featsync.io",
)

Configuration Options

api_key (required)

Your API key from the Featsync dashboard. Each environment has its own API key.

api_key="fs_abc123..."

environment

The environment to evaluate flags against. Defaults to 'production'.

environment="production" # or 'staging', 'development'

base_url

Override the API base URL. Useful for local development or testing.

base_url="http://localhost:3000"

You can also use environment variables:

Terminal window
export FEATSYNC_URL=http://localhost:3000

The SDK checks for FEATSYNC_SDK_BASE_URL or FEATSYNC_URL environment variables automatically.

Built-in Defaults

The SDK uses optimized defaults that work well for most applications:

SettingValueDescription
Cache duration5 minutesFlags are cached to minimize API calls
Request timeout5 secondsBalanced timeout for reliability
PrefetchAlways enabledFlags load immediately on initialization
Stale cacheAlways enabledReturns stale data on API errors

These values are carefully chosen based on best practices and cannot be overridden.

Environment Variables

We recommend using environment variables for configuration:

import os
from featsync import Featsync
client = Featsync(
api_key=os.environ["FEATSYNC_API_KEY"],
environment=os.environ.get("FEATSYNC_ENVIRONMENT", "production"),
)

Django

settings.py
FEATSYNC_API_KEY = os.environ.get("FEATSYNC_API_KEY")
featsync_client.py
from django.conf import settings
from featsync import Featsync
client = Featsync(api_key=settings.FEATSYNC_API_KEY)

Flask

app.py
import os
from flask import Flask
from featsync import Featsync
app = Flask(__name__)
featsync = Featsync(api_key=os.environ.get("FEATSYNC_API_KEY"))

FastAPI

main.py
import os
from fastapi import FastAPI
from featsync import Featsync
app = FastAPI()
featsync = Featsync(api_key=os.environ.get("FEATSYNC_API_KEY"))

Singleton Pattern

Create a single SDK instance and reuse it throughout your application:

lib/featsync_client.py
import os
from featsync import Featsync
client = Featsync(api_key=os.environ["FEATSYNC_API_KEY"])
anywhere.py
from lib.featsync_client import client
if client.is_enabled("my-flag"):
# ...

Thread Safety

The SDK is thread-safe. You can safely share a single instance across multiple threads:

import threading
from featsync import Featsync
# Create one client
client = Featsync(api_key=os.environ["FEATSYNC_API_KEY"])
def worker():
# Safe to use from multiple threads
if client.is_enabled("feature"):
do_work()
# Use across threads
threads = [threading.Thread(target=worker) for _ in range(10)]
for t in threads:
t.start()

Next Steps