Documentation Index
Fetch the complete documentation index at: https://docs.getkaizen.io/llms.txt
Use this file to discover all available pages before exploring further.
Core Concepts
Understand the mental model behind Kaizen before diving into individual APIs.Clients
KaizenClientis an async HTTPX wrapper (python/kaizen_client/client.py) that automatically configures the base URL, timeout, TLS verification, and headers.- Use
KaizenClient.from_env()for short-lived scripts, or instantiateKaizenClient(KaizenClientConfig(...))to override timeouts, headers, or API hosts. - The client is an async context manager; always
async withor callawait client.close()to release sockets.
Requests & responses
- Every write route accepts either plain dictionaries or the typed Pydantic models in
kaizen_client.models. - Responses default to JSON dictionaries containing
operation,status,result, and optionalstats,token_stats, andmetadatablocks. - Use the
metadatafield to pass correlation IDs; Kaizen echoes them back for observability.
Rate limits
- Production SaaS imposes soft rate limits per account. Exceeding them returns HTTP
429with aRetry-Afterheader. - Native retry helpers are on the roadmap (
docs/TODO.md); for now, back off manually and inspectKaizenAPIError.headersfor retry hints.
Error handling
- Network issues raise
KaizenRequestErrorand include the original exception. - Non-2xx responses raise
KaizenAPIErrorwithstatus_code,payload, and headers so you can surface vendor-specific context. - Wrap critical sections in
try/exceptand logpayload.get("detail")when available.
Async vs sync usage
- The core client is async; run it inside
asyncio.run()or convert to sync withasyncio.run(client.compress(...)). - Provider wrappers currently new up synchronous vendor clients; until async variants ship, call them via
asyncio.to_threadinside latency-sensitive services.
Retry behavior
- HTTPX retry hooks are not enabled by default. If you need retries, wrap Kaizen calls in your own helper that catches
KaizenRequestError/KaizenAPIErrorand reapplies exponential backoff. - Include idempotency keys (e.g.,
default_headers={"X-Request-ID": ...}) so retried requests can be traced in Kaizen logs.