Repository navigation
[FEATURE] Estimate the energy use and CO2e of AI requests - #50
Merged
Merged
Conversation
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>
bmack
approved these changes
Nov 6, 2026
bmack
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.