Skip to content

Configuration

Christian KASSE edited this page Apr 2, 2026 · 1 revision

Configuration

Overview

The EssabuConfig dataclass holds all client configuration. Values can be passed explicitly to the constructor or read from environment variables.

Constructor Parameters

from essabu import Essabu

client = Essabu(
    api_key="esa_live_xxx",       # Required
    tenant_id="your-tenant-id",   # Required
    base_url="https://api.essabu.com",  # Optional
    timeout=30.0,                  # Optional (seconds)
    max_retries=3,                 # Optional
)

Environment Variables

Variable Description Default
ESSABU_API_KEY API key for authentication --
ESSABU_TENANT_ID Tenant identifier --
ESSABU_BASE_URL API base URL https://api.essabu.com
ESSABU_TIMEOUT Request timeout (seconds) 30.0
ESSABU_MAX_RETRIES Max retry attempts 3

When both an explicit parameter and an environment variable are set, the explicit parameter takes precedence.

.env File Example

ESSABU_API_KEY=esa_live_abc123def456
ESSABU_TENANT_ID=acme-corp
ESSABU_BASE_URL=https://api.essabu.com
ESSABU_TIMEOUT=60.0
ESSABU_MAX_RETRIES=5

Tip: Use python-dotenv to load .env files automatically.

Accessing Config at Runtime

client = Essabu(api_key="esa_live_xxx", tenant_id="tenant-id")

print(client.config.base_url)    # https://api.essabu.com
print(client.config.timeout)     # 30.0
print(client.config.max_retries) # 3

Retry Behavior

The SDK automatically retries failed requests on transient errors (network issues, 5xx responses, 429 rate limits). The max_retries parameter controls the number of retry attempts. Retries use exponential backoff.

Custom Base URL

For self-hosted or staging environments:

client = Essabu(
    api_key="esa_test_xxx",
    tenant_id="test-tenant",
    base_url="https://staging-api.essabu.com",
)

Validation

Configuration is validated at client creation time. A ValueError is raised if api_key or tenant_id is missing:

try:
    client = Essabu()  # No api_key set anywhere
except ValueError as e:
    print(e)  # "API key is required. Provide it via Essabu(api_key=...) or ESSABU_API_KEY environment variable."

Clone this wiki locally