Skip to content

Track & reduce CO₂ emissions from your local computing

AI can benefit society in many ways, but given the energy needed to support the computing behind AI, these benefits can come at a high environmental price. Use CodeCarbon to track and reduce your CO₂ output from code running on your own hardware. For tracking emissions from remote GenAI API calls (OpenAI, Anthropic, etc.), see EcoLogits.

Get Started


What we are

  • A lightweight, easy to use Python library – Simple API to track emissions
  • Open source, free & community driven – Built by and for the community
  • Effective visual outputs – Put emissions in context with real-world equivalents

Computer emits CO₂. We started measuring how much

A single datacenter can consume large amounts of energy to run computing code. An innovative new tracking tool is designed to measure the climate impact of artificial intelligence.

Kana Lottick, Silvia Susai, Sorelle Friedler, and Jonathan Wilson. Energy Usage Reports: Environmental awareness as part of algorithmic accountability. NeurIPS Workshop on Tackling Climate Change with Machine Learning, 2019.

How it works

  1. Download packagepip install codecarbon
  2. Embed the code – Add a few lines to your script
  3. Run and track – Emissions are measured automatically
  4. Visualize results – See your impact in context

Seamless integration

Only a few lines of code:

from codecarbon import EmissionsTracker

tracker = EmissionsTracker()
tracker.start()

# Your code here

emissions = tracker.stop()
print(f"Emissions: {emissions} kg CO₂")
Section Description
When to use CodeCarbon Local vs remote: CodeCarbon vs EcoLogits
Installation Get started with CodeCarbon
Usage Learn how to use CodeCarbon
API Reference Full API documentation
Examples Example usage patterns
Methodology How emissions are calculated