saef
Python access to SAEF, the SOMA AI Emission Factors. SAEF is an open, versioned dataset of estimated carbon and water factors for AI inference, by model class and region, built for Scope 3 Category 1 reporting under the GHG Protocol and CSRD. This package bundles the CSV files and gives you a small API and command line on top of them. It has no dependencies beyond the standard library.
Every number comes with the file, column and row it was read from, so you can trace an estimate back to the dataset.
Install
pip install saef
For pandas users, pip install "saef[pandas]" adds the optional extra. The framework integrations below use saef[litellm] and saef[langchain].
Example
import saef
print(saef.model_class_for("gpt-4o")) # B
print(saef.factor("B", "eu-west-1")["kg_co2e_per_1m_billed_tokens"])
r = saef.estimate(tokens=1_000_000, model="gpt-4o-mini", region="eu-west-1")
print(r.kg_co2e, r.kg_co2e_high_case) # central and conservative high case, kg CO2e
print(r.water_ml) # mL, or None where the region has no water factor
for s in r.provenance[:3]:
print(s["file"], s["line"], s["column"]) # the file, line and column behind each number
print(len(saef.regions()), saef.__version__, saef.DATASET_VERSION) # 143 cloud regions, 3.1.0, 3.1.0
print(saef.citation())
Command line:
saef estimate --tokens 1000000 --model gpt-4o-mini --region eu-west-1
saef estimate --output-tokens 2e6 --input-tokens 10e6 --model gpt-4o --provider azure --region swedencentral
saef factor --model-class B --region us-east-1
saef regions --provider aws
saef cite
Integrations
The core package has no dependencies. The integrations below estimate carbon and water for each call from the token usage your framework already reports. The region comes from the region argument, then from the SAEF_REGION environment variable, then falls back to the global average. All three keep running totals and can append one JSON line per call with log_path=.
LiteLLM, installed with pip install "saef[litellm]". The estimate is also attached to response._hidden_params["saef"].
import litellm
from saef.integrations.litellm import SaefLogger
logger = SaefLogger(region="eu-west-1")
litellm.callbacks = [logger]
resp = litellm.completion(model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello"}], mock_response="Hi there")
t = logger.totals()
print(t["calls"], t["input_tokens"], t["output_tokens"])
print(f"{t['kg_co2e']:.3e} kg CO2e, {t['kg_co2e_high_case']:.3e} high case, {t['water_ml']:.4f} mL")
1 10 20
3.905e-07 kg CO2e, 6.250e-07 high case, 0.0018 mL
LangChain, installed with pip install "saef[langchain]". This example uses a fake chat model so it runs offline. With a real model you pass the same handler in callbacks.
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import AIMessage
from saef.integrations.langchain import SaefCallbackHandler
handler = SaefCallbackHandler(region="eu-west-1")
reply = AIMessage(
content="Hi there",
response_metadata={"model_name": "gpt-4o"},
usage_metadata={"input_tokens": 1200, "output_tokens": 300, "total_tokens": 1500, "input_token_details": {"cache_read": 800}},
)
llm = GenericFakeChatModel(messages=iter([reply]))
llm.invoke("Hello", config={"callbacks": [handler]})
t = handler.totals()
print(t["calls"], t["input_tokens"], t["cached_input_tokens"], t["output_tokens"])
print(f"{t['kg_co2e']:.3e} kg CO2e, {t['kg_co2e_high_case']:.3e} high case")
1 400 800 300
2.894e-05 kg CO2e, 4.433e-05 high case
Response objects, with no extra install and no SDK import. estimate_from_response reads OpenAI Chat Completions, OpenAI Responses and Anthropic Messages objects, or the same shapes as dicts. Cache reads get the cache credit and cache writes count as ordinary input.
from types import SimpleNamespace
from saef.integrations.openai import estimate_from_response
resp = SimpleNamespace(
type="message", model="claude-sonnet-4-5",
usage=SimpleNamespace(input_tokens=200, output_tokens=150, cache_read_input_tokens=1800, cache_creation_input_tokens=0),
)
e = estimate_from_response(resp, region="eu-west-1")
print(e.model_class, f"{e.kg_co2e:.3e}", f"{e.kg_co2e_high_case:.3e}", f"{e.water_ml:.4f}")
B 2.231e-05 3.235e-05 0.0785
Every figure is an estimate. Models the dataset treats as out of scope, such as embeddings, are skipped and counted in totals()["skipped_calls"].
What the numbers are
The factors follow the v3 lifecycle boundary. An estimate has four terms: electricity, embodied hardware and data-centre construction (charged on effective tokens) and amortised training (charged on billed tokens).
- Effective tokens are output tokens plus weighted input tokens, divided by a reference-mix normaliser. Pass
tokensfor a billed total, which applies the default input share of 85% and no cache credit. Passoutput_tokens,input_tokensandcached_input_tokenswhen your billing export gives the split. - Never multiply a billed token count by a per-effective-token footprint yourself. Use
estimate, or thekg_co2e_per_1m_billed_tokensvalue fromfactor. - A model maps to class A, B or C through 187 identifier patterns, including AWS Bedrock, Azure and Vertex AI spellings. Closed models are class proxies by pricing tier, and the result says so in
warnings. An unmapped identifier is assigned the conservative class C and flagged. Embeddings, image, audio and video models are out of scope and raise an error. regioncan be a cloud region id (143 AWS, Azure and Google Cloud regions), an ISO-3 country code (210 countries and economies), a US eGRID subregion,eu-27, orNonefor the global average. A region that matches nothing raisessaef.SaefErrorwith suggestions.- Water covers 17 regions, under two hydropower conventions (
water_mlandwater_ml_excl_hydro). Elsewherewater_mlisNone, by design. kg_co2e_high_caseis a conservative bound. The development line is reported separately and is never added tokg_co2e.
Estimates, not measurements
These figures are modelled estimates built from published benchmarks, grid averages and lifecycle studies. They are not measurements of any provider's infrastructure. The tables carry six significant figures as arithmetic, but the inputs support about two. Report the central value with the high case, and read the methodology before quoting them.
This package bundles the SAEF v3.1.0 tables (dataset date 2026-10-02, a corrective release of v3.0.0) and covers the H100 central case. Reserved accelerator-hour factors, the B200 sensitivity and the Tier 2b seat-based estimates in the full deposit are not exposed by this API.
Licence
The dataset is licensed under CC BY 4.0. The Python code is licensed under MIT. Attribution for the data is required, see the citation below.
Citation
Dataset (concept DOI, always the latest version): https://doi.org/10.5281/zenodo.20443585
@misc{llopis2026somafactors,
author = {Llopis-Garcia, Guillermo},
title = {{SOMA AI Emission Factors (SAEF)}},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.20443585}
}
Method paper: Llopis-Garcia, G. (2026), Accounting for Purchased Artificial Intelligence Inference in Corporate Greenhouse Gas Inventories, a Token-Based Method. arXiv 2606.10660, accepted for publication in Sustainable Production and Consumption.
Links
Metadata
Release files for saef 3.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| saef-3.1.0.tar.gz | 202.0 kB | With provenance | Details for saef-3.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| saef-3.1.0-py3-none-any.whl | Python 3 | none | any | Details for saef-3.1.0-py3-none-any.whl |
Total release size: 319.9 kB
Release files / saef-3.1.0.tar.gz
| Download URL | saef-3.1.0.tar.gz |
|---|---|
| Size | 202.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9039c69e81846c82f2474c7d534a5aa1dacbedb994d6c1bbd9603fc931ac2835
|
|
BLAKE2b-256 checksum How to use checksums |
7392cef848477746a4441054455065951cf411678a49908d59f3c684e223701d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 12, 2026.
Transparency logRelease files / saef-3.1.0-py3-none-any.whl
| Download URL | saef-3.1.0-py3-none-any.whl |
|---|---|
| Size | 117.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc13e411db813de175c53a0d0f6681e329ff48cbad52b518228486712feb8a04
|
|
BLAKE2b-256 checksum How to use checksums |
899065d38f213fd565c349c0ff40c0a42f263dc4cea047acb4ee412ceb45785f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 12, 2026.
Transparency logSecurity for saef 3.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for saef-3.1.0.tar.gz
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 Nov 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.