Skip to content

Tutorial

The 🌱 EcoLogits library tracks the energy consumption and environmental impacts of generative AI models accessed through APIs and their official client libraries.

It achieves this by patching the Python client libraries, ensuring that each API request is wrapped with an impact calculation function. This function computes the environmental impact based on several request features, such as the chosen model, the number of tokens generated, and the request's latency. The resulting data is then encapsulated in an Impacts object, which is added to the response, containing the environmental impacts for a specific request.

  • Set up in 5 minutes


    Install ecologits with pip and get up and running in minutes.

    Getting started

  • Environmental impacts


    Understand what environmental impacts and phases are reported.

    Tutorial

  • Supported providers


    List of providers and tutorials on how to make requests.

    Providers

  • Methodology


    Understand how we estimate environmental impacts.

    Methodology

Initialization of EcoLogits

To use EcoLogits in your projects, you will need to initialize the client tracers that are used internally to intercept and enrich responses.

Default behavior is to search and initialize all available providers.

from ecologits import EcoLogits

# Initialize for all available providers
EcoLogits.init()

# Initialize for `openai` provider only
EcoLogits.init("openai")

# Initialize for `openai` and `anthropic` providers only
EcoLogits.init(["openai", "anthropic"])

It is currently not possible to un-initialize a provider at runtime. If that's the case do not hesitate to open an issue and explain why it could be necessary for your use case.