kazenai-finops
Stop your AI agents from burning your budget. Catch loops before they catch you.
Install: PyPI · kazenai-finops · Docs: docs.kazenai.com · Products: kazenai.com
Source: github.com/kazenai-ai/kazenai-finops-sdk
What is this?
kazenai-finops is the customer-facing Agent FinOps SDK. Install it, wrap your OpenAI or Anthropic client with monitor(), and get:
- Pre-call budget deny — hard
BudgetExceededbefore a provider call - Soft trajectory pause —
KazenCircuitBreakerwhen projected spend trips (alias:KazenBudgetExceeded) - Loop detection — stop repeated high-risk patterns before another LLM call
- Optional FinOps / Lens evidence — canonical
KazenEventbatches when ingest is configured
It depends on kazenai (the core engine) and kazen-event-schema. Most teams should install this package, not core directly.
Traditional tools: LLM call → response → log cost → dashboard shows overspend
KazenAI: Pre-flight check → BLOCKED → LLM call never made
Install
python -m pip install kazenai-finops openai
# Optional Anthropic path:
# python -m pip install kazenai-finops anthropic
Requires Python 3.10–3.12.
Quick start
from kazenai_finops import monitor, BudgetExceeded, KazenCircuitBreaker
import openai
client = openai.OpenAI()
monitored = monitor(
client,
agent_id="customer-support",
# Optional ingest: set KAZENAI_FINOPS_API_KEY / KAZENAI_FINOPS_URL in the environment
max_budget_usd=5.00,
debug=True,
)
try:
for i in range(100):
monitored.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": f"Step {i}"}],
)
except BudgetExceeded as e:
print(f"Hard cap (before provider): {e}")
except KazenCircuitBreaker as e:
print(f"Soft pause (after a completed call): {e}")
Call sites stay the same — monitor() wraps the client.
Supported today
| Path | Status |
|---|---|
Sync OpenAI chat.completions.create (non-streaming) |
Supported via monitor() |
Sync Anthropic messages.create (non-streaming) |
Supported via monitor() |
| Streaming OpenAI / Anthropic | Experimental / not Control-certified in this release — see docs supported-surface matrix |
| LangChain / LangGraph / CrewAI / AutoGen adapters | Optional extras for evaluation — prefer wrapping the underlying client with monitor() |
Optional framework extras
pip install 'kazenai-finops[langgraph]' # similarly: langchain, crewai, etc. — see pyproject.toml
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
These helpers are for evaluation. For the supported control path, wrap the OpenAI/Anthropic client with monitor().
Streaming (experimental)
For streaming completions, mid-flight cutoff can check spend on token batches:
from kazenai_finops import monitor, StreamCutoffError
import openai
monitored = monitor(
openai.OpenAI(),
agent_id="streaming-agent",
max_budget_usd=1.00,
stream_enforcement=True,
)
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 cut at ${e.blocked_usd:.6f}")
Why local enforcement matters
- Hard cap works offline — no FinOps round-trip required to deny
- Low overhead — checks stay on the hot path
- Backend outage ≠ unprotected spend on the local hard-cap path
How it relates to kazenai
| Package | Role |
|---|---|
kazenai-finops |
Customer SDK (this package) — recommended install |
kazenai |
Core monitor() engine |
kazen-event-schema |
Shared event contract |
from kazenai_finops import monitor re-exports the core engine so existing integrations keep working.
License
Apache License 2.0. See LICENSE and NOTICE.
Issues: https://github.com/kazenai-ai/kazenai-finops-sdk/issues · Products: kazenai.com · founder@kazenai.com
Metadata
Release files for kazenai-finops 1.0.4
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.4.tar.gz | 21.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kazenai_finops-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.0 kB
Release files / kazenai_finops-1.0.4.tar.gz
| Download URL | kazenai_finops-1.0.4.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de358bf0f46cb57cc1a16b54db56680ddadfc7342038c9975bffddeea0a550c8
|
|
BLAKE2b-256 checksum How to use checksums |
9f653c4fece1ddf552be5e447bf9316a1105e0966f1ffa20e68997632790bdf2
|
| 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 Oct 1, 2026.
Transparency logRelease files / kazenai_finops-1.0.4-py3-none-any.whl
| Download URL | kazenai_finops-1.0.4-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ecd95e167aedea24cb93a0f68bee47fc8fc63e3581ec95f7785427d9907d9d28
|
|
BLAKE2b-256 checksum How to use checksums |
1cf86517bda6aa34b4c18adfb25266903cca73a4d146e19f3e3bf947af3bb741
|
| 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 Oct 1, 2026.
Transparency log