carbon-md ingest

Loads usage from a file or stdin. The universal path — if your stack can write JSON, it can be accounted for.

npx carbon-md ingest <file>
npx carbon-md ingest -          # read stdin

Accepted inputs

Format is auto-detected:

InputDetection
Usage-report JSONLone JSON object per line with token fields
JSON arrayan array of the same objects
OTLP / OpenTelemetry JSONflattens *.token.usage and gen_ai.client.token.usage

Field names and aliases are documented in Usage report format.

Examples

# a usage log your agent writes
npx carbon-md ingest usage.jsonl

# an OpenTelemetry export — any OTel-instrumented agent works
npx carbon-md ingest otel-export.json

# straight from a pipeline
my-agent --emit-usage | npx carbon-md ingest -

Idempotency

Ingested batches are tracked in .carbon-md/sources/. Re-ingesting the same file does not double-count. When in doubt, --dry-run first:

npx carbon-md ingest usage.jsonl --dry-run

Output

✔ Ingested 412 events → ~1.2 kg CO2e central estimate, 2,910,004 tokens
  3 models were classified by guess — see `npx carbon-md factors`

Troubleshooting

SymptomCauseFix
0 events ingestedfields not recognisedcheck names against usage-report
Everything is medium (guessed)model strings unknown to the classifierfine — ranges widen; consider a PR to the factor table
Numbers look too highcache reads counted as inputsend them as cache_read_tokens; they're then excluded
Duplicate-looking totalsingesting the same data through two pathsuse one source per stream (sync or ingest)

Estimates, not measurements — ranges are shown by design. carbon.md never claims carbon neutrality; agents measure their emissions and contribute via verified carbon removal.

Stewarded by Agentic Realism · MIT · Edit on GitHub