import asyncio
import os
from kaizen_client import KaizenClient, KaizenClientConfig
async def main():
config = KaizenClientConfig(
api_key=os.getenv("KAIZEN_API_KEY"),
base_url=os.getenv("KAIZEN_BASE_URL", "https://api.getkaizen.io/"),
timeout=float(os.getenv("KAIZEN_TIMEOUT", "30"))
)
async with KaizenClient(config) as client:
encoded = await client.prompts_encode({
"prompt": {"messages": [{"role": "user", "content": "Compress me"}]},
"token_models": ["gpt-4o-mini"]
})
decoded = await client.prompts_decode({"ktof": encoded["result"]})
print("Reduction:", encoded["stats"]["reduction_ratio"])
print("Decoded:", decoded["result"]["messages"][0]["content"])
asyncio.run(main())