litellm-impacts
Environmental impact metrics callback for LiteLLM. Calculates and exposes carbon footprint metrics (energy consumption, CO2 emissions, resource depletion) for LLM API calls using the EcoLogits library.
Installation
pip install litellm-impacts
Or with uv:
uv add litellm-impacts
Usage
With LiteLLM Proxy (config.yaml)
litellm_settings:
callbacks: custom_callbacks.impacts_callback
model_list:
- model_name: gpt-4
litellm_params:
model: openai/gpt-4
Create custom_callbacks.py in the same directory:
from litellm_impacts import ImpactsCallback
impacts_callback = ImpactsCallback()
With LiteLLM Python SDK
import litellm
from litellm_impacts import ImpactsCallback
litellm.callbacks = [ImpactsCallback()]
response = litellm.completion(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)
Configuration Options
from litellm_impacts import ImpactsCallback
callback = ImpactsCallback(
prefix="litellm", # Metric name prefix (default: "litellm")
server_port=8000, # Prometheus HTTP server port (default: 8000)
start_server=True, # Start built-in HTTP server (default: True)
labels=["model", "key_alias"], # Metric labels (default)
)
Set start_server=False if you're already running a Prometheus HTTP server or want to use a different metrics exposition method.
Metrics
The callback exposes the following Prometheus metrics (all with min/max variants):
| Metric | Description |
|---|---|
{prefix}_energy_kwh_min/max |
Energy consumption in kWh |
{prefix}_gwp_kgco2eq_min/max |
Global warming potential in kg CO2 equivalent |
{prefix}_adpe_kgsbeq_min/max |
Abiotic depletion potential in kg Sb equivalent |
{prefix}_pe_mj_min/max |
Primary energy in megajoules |
Labels:
model: The LLM model namekey_alias: The LiteLLM API key alias (if using proxy)
Supported Providers
Models are automatically matched to EcoLogits providers:
- OpenAI (gpt-, o1, o3, o4, chatgpt-)
- Anthropic (claude-*)
- Google (gemini-*)
- Mistral AI (mistral-, codestral-, pixtral-*)
- Cohere (command-*)
Models can also be specified with explicit provider prefixes (e.g., openai/gpt-4, anthropic/claude-3-sonnet).
License
MIT
Metadata
Release files for litellm-impacts 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| litellm_impacts-0.1.0.tar.gz | 168.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| litellm_impacts-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 174.2 kB
Release files / litellm_impacts-0.1.0.tar.gz
| Download URL | litellm_impacts-0.1.0.tar.gz |
|---|---|
| Size | 168.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb0f1f2b10f4ae70b14ac19e3559cca19939d2e9a353145dcf68bc6a09d34844
|
|
BLAKE2b-256 checksum How to use checksums |
e10a32ec40809ecc7076c4a61930a50115f675ef7647208700989de7b6f9617f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2026.
Transparency logRelease files / litellm_impacts-0.1.0-py3-none-any.whl
| Download URL | litellm_impacts-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
738f8b8fc9922d95f22f21c4fa3083904e1a6b1b48857940b2cc0a5cfb6bb36e
|
|
BLAKE2b-256 checksum How to use checksums |
ecf66a97b15a5b8d602b0400ecd77ed9972f0b0ae03e879ad65da6d75cbcea4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 24, 2026.
Transparency log