Skip to main content

KaizenClient

Core async HTTP client that powers every SDK call.

Configuration

OptionTypeDefaultDescription
base_urlstrhttps://api.getkaizen.io/Point to SaaS, staging, or self-hosted deployments.
api_key`strNone`KAIZEN_API_KEY env varBearer token sent as Authorization: Bearer ....
timeoutfloat30.0HTTPX request timeout in seconds.
verify_sslboolTrueDisable only when using custom CA bundles.
default_headersdict[str, str]{}Inject headers such as X-Request-ID.

Usage

from kaizen_client import KaizenClient, KaizenClientConfig

config = KaizenClientConfig(
    api_key="kaizen_xxx",
    base_url="https://api.getkaizen.io/",
    timeout=20,
    default_headers={"X-Request-ID": "docs-demo"}
)

async with KaizenClient(config) as client:
    stats = await client.health()
    print(stats["status"])

Lifecycle helpers

  • KaizenClient.from_env() instantiates a client with env-derived config.
  • with_kaizen_client() decorator (see python/kaizen_client/decorators.py) auto-creates and closes the client for each function invocation.

Notes

  • The client is async; wrap synchronous environments with asyncio.run() or convert methods using asyncio.to_thread.
  • Close the client (await client.close()) when you are done to release sockets if you don’t use the context manager.
  • All high-level methods eventually call httpx.AsyncClient.request and raise KaizenAPIError on non-2xx responses.