Piloterra/ai-co2-estimation
0
AI CO2 Estimation API
Estimate the carbon footprint of AI/LLM usage and get tangible ADEME equivalences.
Built with FastAPI and ecologits.
Quick start (local)
pip install -r requirements.txt
uvicorn app.main:app --reload --port 7860Interactive docs are available at http://localhost:7860/docs.
Cloud deployment
The API is also available in the cloud at:
https://piloterra-ai-co2-estimation.hf.space/estimate
You can call the same POST /estimate endpoint on this URL without running anything locally.
API
POST /estimate
Estimate the carbon impact of a single LLM request.
Request body:
{
"provider": "openai",
"model": "gpt-4o",
"output_tokens": 500,
"request_latency": 1.2
}Response (200):
{
"status": "ok",
"data": {
"gwp_avg_kgco2eq": 0.002,
"gwp_min_kgco2eq": 0.001,
"gwp_max_kgco2eq": 0.003,
"gwp_gco2eq": 2.0,
"energy_kwh": 0.015,
"equivalences": {
"car_km": 0.009132,
"tgv_km": 0.682594,
"water_liters": 0.006231,
"smartphone": 0.000023
}
},
"warnings": [],
"errors": []
}GET /health
Returns {"status": "ok"}.
Running tests
pip install -r requirements.txt
pytest tests/ -vDocker
docker build -t ai-co2-estimation .
docker run -p 7860:7860 ai-co2-estimationEquivalence ratios (ADEME)
Source: Impact CO2
