Tracks dollar cost and CO2e per multi-agent, multi-step agent run, not per API call. A lightweight instrumentation API, a JSONL ledger, and a CLI that produces per-run breakdowns, a ledger-wide summary, and a static HTML dashboard.
config/model_pricing.json and config/carbon_profiles.json ship with illustrative placeholder figures, not verified prices or measured emissions. Every cost and CO2e number this tool reports is only as accurate as those two files. Read the _comment field in each before trusting any output, and see Architecture for what a defensible carbon number would actually require.
Cost tools (LiteLLM, Langfuse, RouteLLM, GPTCache) track spend per API call. Carbon tools (EcoLogits, LLMCarbon, CodeCarbon) estimate emissions per call, largely for research use. Nothing found combines both, at the level a person managing an agentic workflow actually thinks in: what did this whole run cost, in dollars and in CO2e, and which agent or model inside a multi-step, multi-agent workflow drove that. This tool is that rollup.
Token economics and per-inference carbon cost are the boring infrastructure question that will decide which agentic AI programs survive past 2027. This is the companion artifact to that thesis: instrumentation for measuring it, not just writing about it.
from agentic_finops_greenops.ledger import Run
with Run(run_id="support-1001", workflow="customer_support_triage") as run:
run.log_call(agent="Router", model="claude-haiku-4-5", provider="anthropic",
input_tokens=278, output_tokens=21)
run.log_call(agent="Researcher", model="claude-sonnet-5", provider="anthropic",
input_tokens=1181, output_tokens=312)
run.log_call(agent="Responder", model="claude-sonnet-5", provider="anthropic",
input_tokens=671, output_tokens=176)Each log_call computes cost and CO2e immediately (looked up from the config files) and appends one line to a local JSONL ledger, framework-agnostic: it doesn't care whether the calls underneath came from LangChain, CrewAI, AutoGen, or raw API calls, it only needs the token counts.
pip install -r requirements.txt
# generate the bundled example ledger (real, computed by this repo's own code)
python examples/generate_sample_ledger.py
python -m agentic_finops_greenops.cli report --run-id support-1001 --ledger examples/sample_ledger.jsonl
python -m agentic_finops_greenops.cli summary --ledger examples/sample_ledger.jsonl
python -m agentic_finops_greenops.cli dashboard --ledger examples/sample_ledger.jsonl --output dashboard.htmlThis is the actual output of summary against the bundled example ledger (8 synthetic runs across 2 workflows, generated by examples/generate_sample_ledger.py), not a mockup:
## Ledger summary
Runs: 8. Total cost: $354.5820. Total CO2e: 52.38 g. Calls: 24.
### By workflow
| Workflow | Cost | CO2e | Calls | Tokens |
|---|---|---|---|---|
| contract_review_agent | $285.1538 | 37.44 g | 9 | 22081 |
| customer_support_triage | $69.4282 | 14.94 g | 15 | 14472 |
The dashboard (dashboard.html) renders the same data as summary cards, per-workflow and per-agent tables, and two bar charts (cost by workflow, CO2e by agent). Open examples/sample_dashboard.html directly in a browser to see it; no server, no build step.
- Installation guide
- User guide: the instrumentation API, CLI commands, reading every report field.
- Architecture: the cost and carbon models, why they're strict-lookup, known limitations, relationship to EcoLogits/LiteLLM/etc.
docs/ Installation guide, user guide, architecture doc
config/ Pricing and carbon config (edit with your own verified numbers)
schema/ JSON Schema for a call record
agentic_finops_greenops/ The library: pricing, carbon, ledger, report (incl. dashboard), CLI
examples/ Sample data generator + the real ledger and dashboard it produces
tests/ 22 tests, all offline, no network or live model call needed
MIT. See LICENSE.