Skip to content

[FEATURE] Estimate the energy use and CO2e of AI requests - #50

Merged
o-ba merged 1 commit into
mainfrom
feature/environmental-impact
Nov 7, 2026
Merged

o-ba merged 1 commit into
mainfrom
feature/environmental-impact

Conversation

@o-ba

@o-ba o-ba commented Nov 6, 2026

Copy link
Copy Markdown
Member

Every logged text request now stores an estimated energy use (Wh) and CO2e footprint (g), or the reason why it has none.

Hosted requests to OpenAI, Anthropic, Gemini and Mistral are estimated with a PHP port of the EcoLogits LLM inference model. It computes a min-max range from the output tokens, the model size, the provider's PUE and the grid of its data center country. The EcoLogits model and electricity data ship as a subset under MPL-2.0, and Build/Scripts/updateEcoLogitsData.py rebuilds that subset from an upstream checkout.

Configurations with a power draw, for example local Ollama models, use the inference time times that power draw instead. The inference time comes from Ollama's own timings where available, otherwise from the request duration. Both the power draw and the grid intensity can be set per configuration.

A request that cannot be estimated is shown as "No data" with its reason, never as zero, and every total says how many requests it covers. When smart routing answers with a cheaper model, the requested model's estimate for the same answer is stored as well, and the statistics show the CO2e routing avoided or added.

The footprint is shown on the request detail and in the Request Log list (sortable), its statistics card and the Providers overview. A new "AI Footprint" dashboard widget shows the totals and a breakdown per provider.

Run the database analyzer to add the new columns to tx_aim_request_log and tx_aim_configuration.

Every logged text request now stores an estimated energy use (Wh) and
CO2e footprint (g), or the reason why it has none.

Hosted requests to OpenAI, Anthropic, Gemini and Mistral are estimated
with a PHP port of the EcoLogits LLM inference model. It computes a
min-max range from the output tokens, the model size, the provider's
PUE and the grid of its data center country. The EcoLogits model and
electricity data ship as a subset under MPL-2.0, and
Build/Scripts/updateEcoLogitsData.py rebuilds that subset from an
upstream checkout.

Configurations with a power draw, for example local Ollama models, use
the inference time times that power draw instead. The inference time
comes from Ollama's own timings where available, otherwise from the
request duration. Both the power draw and the grid intensity can be set
per configuration.

A request that cannot be estimated is shown as "No data" with its
reason, never as zero, and every total says how many requests it
covers. When smart routing answers with a cheaper model, the requested
model's estimate for the same answer is stored as well, and the
statistics show the CO2e routing avoided or added.

The footprint is shown on the request detail and in the Request Log
list (sortable), its statistics card and the Providers overview. A new
"AI Footprint" dashboard widget shows the totals and a breakdown per
provider.

Run the database analyzer to add the new columns to tx_aim_request_log
and tx_aim_configuration.

Signed-off-by: Oliver Bartsch <bo@cedev.de>
@o-ba
o-ba requested a review from bmack November 6, 2026 12:11
@o-ba
o-ba merged commit bf69c56 into main Nov 7, 2026
13 checks passed
@o-ba
o-ba deleted the feature/environmental-impact branch November 7, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants