Skip to main content

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.

PyPI MIT DOI Listed in LangChain docs

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
ShipCIICalculator yes A ship's IMO Carbon Intensity Indicator and A–E rating for 2023–2030 from its type, capacity, distance and fuel, with the IMO resolution behind each parameter. Without a key it computes nothing 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 four 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.

Metadata

Release files for langchain-greencalculus 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-greencalculus 0.2.0
File Size Uploaded Provenance Actions
langchain_greencalculus-0.2.0.tar.gz 15.3 kB With provenance Details for langchain_greencalculus-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-greencalculus 0.2.0
File Interpreter ABI Platform Actions
langchain_greencalculus-0.2.0-py3-none-any.whl Python 3 none any Details for langchain_greencalculus-0.2.0-py3-none-any.whl

Total release size: 27.1 kB

Release files / langchain_greencalculus-0.2.0.tar.gz

Download URL langchain_greencalculus-0.2.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3489d0e65f268f7d13bf9b6378fd15f8743f7687ed07f318b6a63cf670955e12
BLAKE2b-256 checksum
How to use checksums
eaf4ad9f64159bc65c4e27a276e76ee750b1daed72ddca89e868b956e4aff0af
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 Oct 31, 2026.

Transparency log

Release files / langchain_greencalculus-0.2.0-py3-none-any.whl

Download URL langchain_greencalculus-0.2.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0361c77836238021e5f321a5c954d49e7018f8ae8032ba687c5ec612d502952c
BLAKE2b-256 checksum
How to use checksums
5c1cd6d4c5a822c078b67c8483ccb44af0694838f6a474532ceccdf1064c2d7c
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 Oct 31, 2026.

Transparency log

Security for langchain-greencalculus 0.2.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_greencalculus-0.2.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 Oct 31, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page