Skip to content

Configuration

The smplkit SDKs resolve configuration from multiple sources with well-defined precedence. You can configure the SDK entirely through environment variables, a configuration file, constructor arguments, or any combination.

Precedence

Configuration is resolved in this order. Each step overlays only the keys it provides:

  1. SDK defaults — built-in fallback values
  2. Configuration file (~/.smplkit) — profiles with shared defaults
  3. Environment variables (SMPLKIT_*) — override file config
  4. Constructor arguments — override everything

A key set at a higher-numbered layer always wins. Keys not set at that layer fall through to the next layer down.

Configuration File

The configuration file at ~/.smplkit uses INI format with named profiles and a [common] section for shared defaults.

ini
# Shared defaults applied to every profile
[common]
api_key = sk_api_abc123
debug = false
disable_telemetry = false

# Default profile — used when no profile is specified
[default]
environment = production
service = my-service

# Local development
[local]
base_domain = localhost
scheme = http
environment = local
service = my-service
debug = true

# Staging
[staging]
environment = staging
service = my-service

Values from [common] are applied first, then the active profile overlays its keys on top.

Configuration Reference

File KeyEnv VarTypeDefaultDescription
api_keySMPLKIT_API_KEYstring(required)Account-scoped API key
base_domainSMPLKIT_BASE_DOMAINstringsmplkit.comBase domain for API requests
schemeSMPLKIT_SCHEMEstringhttpsURL scheme (http for local dev)
environmentSMPLKIT_ENVIRONMENTstring(required)Runtime environment key
serviceSMPLKIT_SERVICEstring(required)Runtime service key
debugSMPLKIT_DEBUGboolfalseEnable debug logging
disable_telemetrySMPLKIT_DISABLE_TELEMETRYboolfalseDisable metric reporting

Boolean values accept: true, 1, yes (truthy) and false, 0, no (falsy), case-insensitive.

Profiles

The SDK loads the [default] profile unless you specify otherwise. Select a different profile with:

  • Environment variable: SMPLKIT_PROFILE=local
  • Constructor argument: pass profile to the client constructor

The constructor argument takes precedence over the environment variable.

Profile resolution:

  1. Start with [common] values (if the section exists)
  2. Overlay the selected profile's values
  3. Overlay any SMPLKIT_* environment variables
  4. Overlay any constructor arguments

Usage

Auto-resolve (no arguments)

With a config file or environment variables in place, the client resolves everything automatically:

python
from smplkit import SmplClient

with SmplClient() as client:
    # Resolves api_key, environment, service from
    # ~/.smplkit [default] profile or SMPLKIT_* env vars
    pass

Named profile

Select a profile to load its configuration:

python
from smplkit import SmplClient

with SmplClient(profile="local") as client:
    # Loads [common] + [local] from ~/.smplkit
    pass

Explicit overrides

Constructor arguments override all other sources:

python
from smplkit import SmplClient

with SmplClient(
    api_key="sk_api_abc123",
    environment="staging",
    service="my-service",
    profile="staging",
    debug=True,
) as client:
    pass

Precedence Example

Given this config file:

ini
[common]
api_key = sk_api_from_file
debug = false

[default]
environment = production
service = web-app

And this environment variable:

bash
export SMPLKIT_ENVIRONMENT=staging

And this constructor call:

python
client = SmplClient(debug=True)

The resolved configuration is:

KeyValueSource
api_keysk_api_from_fileConfig file [common]
environmentstagingEnvironment variable (overrides file)
serviceweb-appConfig file [default]
debugtrueConstructor argument (overrides everything)

Tips

Local development — Create a [local] profile that points to your local platform:

ini
[local]
base_domain = localhost
scheme = http
environment = local
service = my-service
debug = true

Then start the client with profile="local" or set SMPLKIT_PROFILE=local.

Shell integration — Use direnv to auto-switch profiles per project. Add to your .envrc:

bash
export SMPLKIT_PROFILE=local

Or create shell aliases:

bash
alias smpl-local='export SMPLKIT_PROFILE=local'
alias smpl-staging='export SMPLKIT_PROFILE=staging'
alias smpl-prod='unset SMPLKIT_PROFILE'  # falls back to [default]

CI/CD — In CI pipelines, skip the config file entirely. Set SMPLKIT_API_KEY, SMPLKIT_ENVIRONMENT, and SMPLKIT_SERVICE as pipeline variables. The SDK resolves them without needing ~/.smplkit.