Skip to content

EcoLogits EcoLogits

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-3.5-Turbo 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(
    model="gpt-3.5-turbo",
    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")
print(f"GHG emissions: {response.impacts.gwp.value} kgCO2eq")

Environmental impacts are quantified based on four criteria and across two phases:

Criteria:

  • Energy (energy): Final energy consumption in kWh,
  • Global Warming Potential (gwp): Potential impact on global warming in kgCO2eq (commonly known as GHG/carbon emissions),
  • Abiotic Depletion Potential for Elements (adpe): Impact on the depletion of non-living resources such as minerals or metals in kgSbeq,
  • Primary Energy (pe): Total energy consumed from primary sources in MJ.

Phases:

  • Usage (usage): Represents the phase of energy consumption during model execution,
  • Embodied (embodied): Encompasses resource extraction, manufacturing, and transportation phases associated with the model's lifecycle.

Learn more about environmental impacts assessment in the 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.