

EcoLogits tracks the energy consumption and environmental impacts of using generative AI models through APIs. It supports major LLM providers such as OpenAI, Anthropic, Mistral AI and more (see supported providers).
EcoLogits was created and is actively maintained by the GenAI Impact non-profit.
Requirements
Python 3.9+
EcoLogits relies on key libraries to provide essential functionalities:
Installation
Select providers
Run this command
For detailed instructions on each provider, refer to the complete list of supported providers and features. It is also possible to install EcoLogits without any provider.
Usage Example
Below is a simple example demonstrating how to use the GPT-4o-mini model from OpenAI with EcoLogits to track environmental impacts.
from ecologits import EcoLogits
from openai import OpenAI
# Initialize EcoLogits
EcoLogits.init()
client = OpenAI(api_key="<OPENAI_API_KEY>")
response = client.chat.completions.create( # (1)!
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "Tell me a funny joke!"}
]
)
# Get estimated environmental impacts of the inference
print(f"Energy consumption: {response.impacts.energy.value} kWh") # (2)!
print(f"GHG emissions: {response.impacts.gwp.value} kgCO2eq") # (3)!
# Get potential warnings
if response.impacts.has_warnings:
for w in response.impacts.warnings:
print(w) # (4)!
# Get potential errors
if response.impacts.has_errors:
for w in response.impacts.errors:
print(w) # (5)!
- You don't need to change your code when making a request!
- Total estimated energy consumption for the request in kilowatt-hour (kWh). You can expect an interval, see exemple here.
- Total estimated greenhouse gas emissions for the request in kilogram of CO2 equivalent (kgCO2eq). You can expect an interval, see exemple here.
- For
gpt-4o-mini
, you can expect two warnings:model-arch-not-released
andmodel-arch-multimodal
. - On this example you shouldn't get any errors.
Impacts output in a nutshell
ImpactsOutput
object is returned for each request made to supported clients. It gathers, environmental impacts and potential warnings and errors.
EcoLogits aims to give a comprehensive view of the environmental footprint of generative AI models at inference. Impacts are reported in total, but also per life cycle phases:
- Usage: related to the impacts of the energy consumption during model execution.
- Embodied: related to resource extraction, manufacturing and transportation of the hardware.
And, multiple criteria:
- Energy: related to the final electricity consumption in kWh.
- Global Warming Potential (GWP): related to climate change, commonly known as GHG emissions in kgCO2eq.
- Abiotic Depletion Potential for Elements (ADPe): related to the depletion of minerals and metals in kgSbeq.
- Primary Energy (PE): related to the energy consumed from primary sources like oil, gas or coal in MJ.
For detailed instructions on how to use the library, see our tutorial section. If you want more details on the underlying impacts calculations, see our methodology section.
License
This project is licensed under the terms of the Mozilla Public License Version 2.0 (MPL-2.0) .
Acknowledgements
We extend our gratitude to Data For Good and Boavizta for supporting the development of this project. Their contributions of tools, best practices, and expertise in environmental impact assessment have been invaluable.