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

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

langchain_greencalculus-0.1.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_greencalculus-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

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

Hashes for langchain_greencalculus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ea0338024bf545f0715b15feb1dc1fde577e25a46fd095128672c2c7d26040c
MD5 696972a1954ffd3a1b82c854feae13be
BLAKE2b-256 271445f7f4835d24be6cd80052d41ca7ea25913c26965981f2eea968873b41c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_greencalculus-0.1.1.tar.gz:

Publisher: release.yml on greencalculus/langchain-greencalculus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_greencalculus-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_greencalculus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 193945304adaa29b601d8ef5c8519eada3c87ec898d1b181e6b3a50c37c09ca9
MD5 269f224e93dec145bd10bb36f1a2cccf
BLAKE2b-256 38ede657b937421dcb2533867faede5f6bc75a9770910f26374494f0a375a9d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_greencalculus-0.1.1-py3-none-any.whl:

Publisher: release.yml on greencalculus/langchain-greencalculus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

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