langchain-greencalculus
LangChain tools for sourced greenhouse-gas emission factors. Every value comes back with the publisher, the exact place it was read from, and a citation your agent can repeat.
pip install langchain-greencalculus
Why this exists
We put 467 emission-factor questions to five frontier models with no tools. They were correct 46% of the time — and, worse, they named the right publisher while giving the wrong number in up to 59% of answers.
That is the failure that survives review. A wrong number with no source gets caught. A wrong number wearing DEFRA's name does not.
Given a sourced lookup tool, the same models reached 99–100%.
Those figures are measured and reproducible, not marketing: the questions, every raw model answer and the scoring code are published, with a DOI (10.5281/zenodo.22692277) and on HuggingFace. The study also reports the parts that reflect badly on us.
This package is the fix that study describes.
No API key needed to start
The corpus is open to read, so the tools work before anyone signs up:
from langchain_greencalculus import EmissionFactorLookup
print(EmissionFactorLookup().invoke({"key": "grid.gbr.electricity.location_based"}))
0.13096 kg CO2e per kWh
key: grid.gbr.electricity.location_based
citation: UK grid electricity — location-based (generation). UK Government GHG
Conversion Factors 2026 — Department for Energy Security and Net Zero (DESNZ),
cell 'UK electricity'!E25, retrieved 2026-06-18. via GreenCalculus data version
2026.189, factor grid.gbr.electricity.location_based.
https://verify.greencalculus.com/grid.gbr.electricity.location_based@2026.189
That cell reference is the point. The number is traceable to a row in a government workbook, not to a blog post.
Use it in an agent
from langchain.agents import create_agent
from langchain_greencalculus import (
EmissionFactorLookup, EmissionFactorSearch, EmissionsCalculator,
)
tools = [EmissionFactorSearch(), EmissionFactorLookup(), EmissionsCalculator()]
agent = create_agent("anthropic:claude-sonnet-5", tools=tools)
agent.invoke({"messages": [{"role": "user",
"content": "We used 12,000 kWh of UK grid electricity. What are the emissions, and cite the source."}]})
The tool descriptions tell the model to search before guessing a key, to prefer the tool over recall, and to repeat the citation. They also warn it about the distinctions that silently produce a plausible wrong answer — location-based vs market-based, well-to-tank vs combustion.
The tools
| Tool | Needs a key | What it does |
|---|---|---|
EmissionFactorSearch |
no | Plain-English search, returns candidate keys with values and publishers |
EmissionFactorLookup |
no | One factor by exact key, with its citation. as_of pinning needs a key |
EmissionsCalculator |
optional | Quantity × factor. With a key you get a server-side audit trail; without one it multiplies locally and says so |
Configuration
EmissionFactorLookup(api_key="gc_live_…") # explicit
Or set GREENCALCULUS_API_KEY and construct with no arguments. A free key
(1,000 calls/month, no card) is at
greencalculus.com/developers.
A key adds: as_of version pinning so a figure reproduces a year later, traced
server-side calculations, and higher rate limits.
Standard tests
This package runs LangChain's own conformance suite — ToolsUnitTests and
ToolsIntegrationTests from
langchain-tests — against all
three tools, sync and async.
pip install -e ".[test]" && pytest
The integration tests hit the live open route, so they pass with no secret configured. Nothing here is mocked into looking like it works.
Listed in LangChain's own integration docs — as
GreenCalculusToolkit
in the Python tools directory, and as a provider in
all providers.
Licence
MIT. The emission factors themselves carry their publishers' licences, which are returned with each value and audited in full — 42% of the 137 sources we read carry no standard licence at all.
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 langchain_greencalculus-0.1.1.tar.gz.
File metadata
- Download URL: langchain_greencalculus-0.1.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ea0338024bf545f0715b15feb1dc1fde577e25a46fd095128672c2c7d26040c
|
|
| MD5 |
696972a1954ffd3a1b82c854feae13be
|
|
| BLAKE2b-256 |
271445f7f4835d24be6cd80052d41ca7ea25913c26965981f2eea968873b41c9
|
Provenance
The following attestation bundles were made for langchain_greencalculus-0.1.1.tar.gz:
Publisher:
release.yml on greencalculus/langchain-greencalculus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_greencalculus-0.1.1.tar.gz -
Subject digest:
6ea0338024bf545f0715b15feb1dc1fde577e25a46fd095128672c2c7d26040c - Sigstore transparency entry: 2831487017
- Sigstore integration time:
-
Permalink:
greencalculus/langchain-greencalculus@e069f3b4a75c70dd07216932d9b3d9444f94d3a2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/greencalculus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e069f3b4a75c70dd07216932d9b3d9444f94d3a2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_greencalculus-0.1.1-py3-none-any.whl.
File metadata
- Download URL: langchain_greencalculus-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
193945304adaa29b601d8ef5c8519eada3c87ec898d1b181e6b3a50c37c09ca9
|
|
| MD5 |
269f224e93dec145bd10bb36f1a2cccf
|
|
| BLAKE2b-256 |
38ede657b937421dcb2533867faede5f6bc75a9770910f26374494f0a375a9d5
|
Provenance
The following attestation bundles were made for langchain_greencalculus-0.1.1-py3-none-any.whl:
Publisher:
release.yml on greencalculus/langchain-greencalculus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_greencalculus-0.1.1-py3-none-any.whl -
Subject digest:
193945304adaa29b601d8ef5c8519eada3c87ec898d1b181e6b3a50c37c09ca9 - Sigstore transparency entry: 2831487135
- Sigstore integration time:
-
Permalink:
greencalculus/langchain-greencalculus@e069f3b4a75c70dd07216932d9b3d9444f94d3a2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/greencalculus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e069f3b4a75c70dd07216932d9b3d9444f94d3a2 -
Trigger Event:
push
-
Statement type: