Python SDK for the CrbonFree carbon-offset API
Project description
crbonfree
Measure and offset the carbon footprint of your AI workloads.
One SDK. Every major provider. Verified retirement receipts.
pip install crbonfree
Get started
1. Log in (one command — no dashboard needed)
crbonfree login
Opens your browser, creates an account (or signs in), generates an API key, and saves it locally.
2. Use the SDK
from crbonfree import CrbonFree
crbon = CrbonFree() # reads saved credentials automatically
summary = crbon.telemetry.get_summary()
print(f"{summary.data.total_co2_kg} kg CO₂ from your AI usage")
No API key to copy-paste. No env vars to set. Just crbonfree login and go.
Works with
OpenAI · Anthropic · OpenRouter · AWS Bedrock · and growing
Connect your provider accounts. We meter the inference. You get the emissions data + signed retirement receipts.
What you can do
| Method | What it returns | |
|---|---|---|
| Measure | crbon.telemetry.get_summary() |
Total CO₂, per-model rollups, daily chart |
| Analyze | crbon.usage.get_breakdown() |
Which models cost the most carbon |
| Organize | crbon.projects.list() |
Track emissions by project / team |
| Prove | crbon.billing.list_receipts() |
Signed carbon retirement receipts |
| Audit | crbon.billing.list_audit_packs() |
CSRD-ready compliance artifacts |
| Manage | crbon.apikeys.create() |
Programmatic API key management |
Full API surface (8 sub-clients, 40+ methods)
| Sub-client | What it does | Key methods |
|---|---|---|
crbon.auth |
Session + user metadata | me(), register(), update_profile(), delete_account() |
crbon.apikeys |
API key management | list(), create(), revoke() |
crbon.connections |
Provider connections | list(), create(), get(), sync(), delete() |
crbon.projects |
Workspace organization | list(), create(), get(), update(), delete() |
crbon.usage |
Aggregated analytics | get_summary(), get_breakdown(), get_daily(), export_daily() |
crbon.subscriptions |
Billing lifecycle | get(), get_estimate(), update_cap(), save_payment_method() |
crbon.telemetry |
Event-level emissions | get_summary(), list_events(), list_models() |
crbon.billing |
Receipts + compliance | list_periods(), list_receipts(), list_audit_packs(), get_plan_tier() |
Every sync method has an async twin on AsyncCrbonFree.
Authentication
Auto-login (recommended — zero config after first run)
crbonfree login
Saves your API key to ~/.crbonfree/credentials (the same file the MCP server and TS SDK use). The client reads it automatically — no constructor args needed:
from crbonfree import CrbonFree
crbon = CrbonFree()
crbonfree logout # remove saved credentials
crbonfree whoami # check who you're logged in as
Explicit API key (for CI / env-var workflows)
import os
from crbonfree import CrbonFree
crbon = CrbonFree(api_key=os.environ["CRBONFREE_API_KEY"])
Or set the variable and let the client pick it up:
export CRBONFREE_API_KEY="ck_live_..."
crbon = CrbonFree()
When you omit api_key, the client resolves it in order: the explicit api_key=
argument → the CRBONFREE_API_KEY environment variable → the
~/.crbonfree/credentials file written by crbonfree login. If none are found
it raises MissingCredentialsError (importable from crbonfree.client). The
resolved key is sent on every request as the X-API-Key header.
Async
import asyncio
from crbonfree import AsyncCrbonFree
async def main():
crbon = AsyncCrbonFree() # same credential resolution as the sync client
summary = await crbon.telemetry.get_summary()
print(f"{summary.data.total_co2_kg} kg CO₂ from your AI usage")
asyncio.run(main())
Pagination
Listing endpoints accept page and limit directly, but the helpers drive the
page loop for you:
from crbonfree.pagination import auto_paginate, collect_all
# Stream every item across all pages
for receipt in auto_paginate(crbon.billing.list_receipts, limit=100):
print(receipt.serial_number)
# Or pull everything into a list at once
receipts = collect_all(crbon.billing.list_receipts, limit=100)
Async clients get auto_paginate_async and collect_all_async. These apply to
the paginated list endpoints — billing.list_receipts,
billing.list_audit_packs, billing.list_overages, billing.list_periods, and
telemetry.list_events. Capped-list endpoints (connections.list,
projects.list, apikeys.list, telemetry.list_models) return plain lists and
need no pagination.
Error handling
Failed requests raise typed exceptions carrying the status code and parsed body:
from crbonfree import CrbonFree, NotFoundError
crbon = CrbonFree()
try:
crbon.projects.get(id="nope")
except NotFoundError as err:
print(err.status_code, err.body) # 404, with a typed ErrorResponse
All error types
| Error | Status |
|---|---|
BadRequestError |
400 |
UnauthorizedError |
401 |
PaymentRequiredError |
402 |
ForbiddenError |
403 |
NotFoundError |
404 |
ConflictError |
409 |
TooManyRequestsError |
429 |
InternalServerError |
500 |
ServiceUnavailableError |
503 |
All are importable from crbonfree and extend ApiError
(crbonfree.core.api_error) with status_code, headers, and body. Missing
credentials raise MissingCredentialsError.
Configuration
from crbonfree import CrbonFree
crbon = CrbonFree(
api_key="...", # explicit key (overrides env + saved credentials)
timeout=30, # seconds
max_retries=3,
base_url="https://custom.api/",
)
MCP server
Want to give AI agents direct access to your carbon data? Check out
@crbonfree/mcp — works with
Claude Desktop, Cursor, and any MCP-compatible client, and shares the same
~/.crbonfree/credentials login.
MIT — Crbon Labs Inc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crbonfree-0.2.0.tar.gz.
File metadata
- Download URL: crbonfree-0.2.0.tar.gz
- Upload date:
- Size: 106.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
257d7e938cdb5afaeaa2f5c9e3d3de0978da2db113e8b6b9b5f21bf1039fcb66
|
|
| MD5 |
96b060afeab61199be2991008f620e96
|
|
| BLAKE2b-256 |
21726ffa5b9faf3423045353d409380c7fc1175acadf8f6f7ea8ed24e53bed46
|
Provenance
The following attestation bundles were made for crbonfree-0.2.0.tar.gz:
Publisher:
publish.yml on Crbon-Labs-Inc/crbonfree-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crbonfree-0.2.0.tar.gz -
Subject digest:
257d7e938cdb5afaeaa2f5c9e3d3de0978da2db113e8b6b9b5f21bf1039fcb66 - Sigstore transparency entry: 1696007883
- Sigstore integration time:
-
Permalink:
Crbon-Labs-Inc/crbonfree-python-sdk@485f84c601bb2e73bc5016920f31e1d1065ac486 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Crbon-Labs-Inc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@485f84c601bb2e73bc5016920f31e1d1065ac486 -
Trigger Event:
push
-
Statement type:
File details
Details for the file crbonfree-0.2.0-py3-none-any.whl.
File metadata
- Download URL: crbonfree-0.2.0-py3-none-any.whl
- Upload date:
- Size: 178.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dfcb19109c2601f40d62ef1da321a6c1d3dabd61ef8d7ddbbbd3c6bce2f5870
|
|
| MD5 |
8e102bea6732fb4b50ba931770efec3f
|
|
| BLAKE2b-256 |
2694b51ce3da44bb318bbdf6ba42843109972edd839d31d3cae2534e071b0ccd
|
Provenance
The following attestation bundles were made for crbonfree-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Crbon-Labs-Inc/crbonfree-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
crbonfree-0.2.0-py3-none-any.whl -
Subject digest:
3dfcb19109c2601f40d62ef1da321a6c1d3dabd61ef8d7ddbbbd3c6bce2f5870 - Sigstore transparency entry: 1696007989
- Sigstore integration time:
-
Permalink:
Crbon-Labs-Inc/crbonfree-python-sdk@485f84c601bb2e73bc5016920f31e1d1065ac486 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Crbon-Labs-Inc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@485f84c601bb2e73bc5016920f31e1d1065ac486 -
Trigger Event:
push
-
Statement type: