kazenai-finops
Control FINAL_1 scope: Only sync OpenAI Chat Completions + Anthropic Messages via
kazenai.monitor/kazenai_finops.monitorare Control-certified (seedocs/integrations/control-supported-matrix.md). Framework adapters, streaming mid-flight cutoff, and durable checkpoint/resume are shipped as extras or experimental paths — not Control-supported unless a matrix cell is raised with evidence.
Stop your AI agents from burning your budget. Catch loops before they catch you.
Install: PyPI · kazenai-finops · Products: kazenai.com
kazenai-finops is the customer-facing Agent FinOps SDK. It wraps supported LLM clients and adds budget enforcement, loop detection, and optional event ingest for Agent FinOps / Agent Lens.
Published on PyPI as kazenai-finops (depends on kazenai and kazen-event-schema). Prefer pip install kazenai-finops. Editable sibling installs below are for workspace contributors only.
What the Control-certified path provides today:
- Pre-call budget deny — hard
BudgetExceededbefore a provider call when the configured cap would be exceeded. - Soft trajectory pause —
KazenCircuitBreakerafter a completed call when projection trips (alias:KazenBudgetExceeded). - Loop detection — blocks repeated high-risk patterns before another provider call.
- Optional FinOps ingest — canonical
KazenEventbatches whenKAZENAI_FINOPS_URL/ API key are set (HttpSink).
# pip install kazenai-finops openai
from kazenai_finops import monitor, BudgetExceeded
import openai
client = openai.OpenAI()
monitored = monitor(
client,
agent_id="customer-support",
# set KAZENAI_FINOPS_API_KEY in the environment (not a monitor kwarg)
max_budget_usd=5.00,
debug=True,
)
# Certified Control path: sync chat.completions.create (non-streaming).
Installation
python -m pip install kazenai-finops openai
# Optional Anthropic path:
# python -m pip install kazenai-finops anthropic
Requires Python 3.10–3.12. Also installs transitive kazenai and kazen-event-schema.
Workspace / contributor install (optional)
From a full KazenAI workspace checkout:
python -m venv .venv-finops-sdk
. .venv-finops-sdk/bin/activate
pip install -e ./kazen-event-schema
pip install --no-deps -e ./kazenai-core
pip install -e ./kazenai-finops-sdk
Optional extras are defined in pyproject.toml, for example
pip install 'kazenai-finops[langgraph]' (framework adapters — not Control-certified in FINAL_1).
Quick Start
Raw OpenAI (Control-certified)
from kazenai_finops import monitor, BudgetExceeded, KazenCircuitBreaker
import openai
client = openai.OpenAI()
monitored = monitor(
client,
agent_id="my-agent",
# KAZENAI_FINOPS_API_KEY env — https://kazenai.com
max_budget_usd=0.50,
debug=True,
)
try:
for i in range(100):
response = monitored.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": f"Step {i}"}],
)
except BudgetExceeded as e: # hard pre-call cap
print(f"Hard cap: {e}")
except KazenCircuitBreaker as e: # soft post-call pause (alias: KazenBudgetExceeded)
print(f"Soft pause: {e}")
Framework adapters (not Control-certified)
These helpers exist in the package for evaluation. They are not FINAL_1 Control-certified. Prefer wrapping the underlying OpenAI/Anthropic client with monitor() for the supported path.
# Optional extras — see pyproject.toml [project.optional-dependencies]
from kazenai_finops.adapters.langchain import wrap_langchain_runnable
from kazenai_finops.adapters.langgraph import wrap_graph_invoke
from kazenai_finops.adapters.crewai import wrap_crew_kickoff
from kazenai_finops.adapters.autogen import wrap_conversable_agent
Mid-stream budget enforcement (SSE)
Not Control-certified in FINAL_1. Streaming / mid-flight cutoff is an experimental path.
For streaming completions (stream=True), enable FinOps mid-flight cutoff so spend is
checked on every token batch — not only at call start:
from kazenai_finops import monitor, StreamCutoffError
import openai
client = openai.OpenAI()
monitored = monitor(
client,
agent_id="streaming-agent",
# set KAZENAI_FINOPS_API_KEY in the environment (not a monitor kwarg)
max_budget_usd=1.00,
stream_enforcement=True, # POST /v1/budget/stream-tick during SSE
)
try:
stream = monitored.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Long answer please"}],
stream=True,
)
for chunk in stream:
...
except StreamCutoffError as e:
print(f"Stream severed at ${e.blocked_usd:.6f} ({e.total_tokens} tokens)")
Set KAZENAI_FINOPS_URL and KAZENAI_FINOPS_STREAM_ENFORCE=1 on the orchestrator for
the same behavior on stream_model() chat paths.
Why local-first enforcement matters
Most observability tools record what happened. KazenAI can block what's about to happen on the certified sync path.
Traditional tools: LLM call → response → log cost → dashboard shows overspend
KazenAI (local): Pre-flight check → BLOCKED → LLM call never made
Local enforcement means:
- Works offline for the hard cap — no FinOps network round-trip required to deny
- Low overhead — budget check completes locally on the hot path
- Backend outage ≠ unprotected spend for the local hard-cap path — optional ingest may still fail open depending on configuration
How it relates to kazenai (core)
kazenai-finops is the customer-facing package name on PyPI. It re-exports and depends on kazenai (this workspace’s kazenai-core repo), which provides monitor(), enforcement primitives, and shared wiring to kazen-event-schema. Integrators who need lower-level APIs may depend on kazenai directly.
Roadmap (honesty)
| Status | What |
|---|---|
| Control-certified now | Sync OpenAI Chat Completions + Anthropic Messages via monitor() |
| In package, not Control-certified | LangChain / LangGraph / CrewAI / AutoGen adapters; streaming mid-flight |
| Product / future | Broader dashboard and investigation surfaces — see product site; not claimed as SDK certification |
Do not treat optional adapters or future roadmap items as Control-supported without matrix evidence.
License
Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.
Issues and feedback: https://github.com/KazenAI/kazenai-finops/issues
Products and design-partner enquiries: https://kazenai.com · founder@kazenai.com
Release files for kazenai-finops 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kazenai_finops-1.0.2.tar.gz | 22.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kazenai_finops-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.6 kB
Release files / kazenai_finops-1.0.2.tar.gz
| Download URL | kazenai_finops-1.0.2.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ad68d49a6708ea9fd4c318e0bb032598acf3b0b618d55effa15eb70abb6b0f3
|
|
BLAKE2b-256 checksum How to use checksums |
a517c757f3df7dfd5f61a5257177b1adb0572ffeb33af61a2cd5882655dc7571
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / kazenai_finops-1.0.2-py3-none-any.whl
| Download URL | kazenai_finops-1.0.2-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a58abd4819fb22ff5eaf8881e16874b3d81ce5a2275302406584bb3815b07364
|
|
BLAKE2b-256 checksum How to use checksums |
f735dca23f03ef2f32248669fd367bdf19219fd98cfdf6c6d88504e67e39c3e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log