# pi-carbon-footprint

See the estimated environmental impact of your current [Pi](https://github.com/earendil-works/pi) session directly in the UI.

The session total is shown as CO₂ equivalent and water consumption, giving you a compact view of the footprint behind your model usage.

![pi-carbon-footprint screenshot](./preview.webp)

## Command-line options

- `--footprint-zone <ISO3>`: electricity mix zone to use for EcoLogits estimates. Defaults to `WOR`.
- `--no-footprint`: disable footprint estimates for the session.

Example:

```bash
pi --footprint-zone USA
```

## Commands

- `/footprint`: show current-session details, including per-model output tokens and CO₂/water estimate totals.

## Install/use

Install the extension package from npm:

```bash
pi install npm:@andi0b/pi-carbon-footprint
```

Then start Pi normally; the installed extension is discovered automatically:

```bash
pi --footprint-zone USA
```

You can also install it from a local checkout during development:

```bash
pi install /path/to/pi-carbon-footprint
pi
```

## How estimates work

For each assistant response, the extension sums output tokens by provider/model, then calls the [EcoLogits](https://ecologits.ai/) estimation endpoint once per `(provider, model, electricity mix zone)` with `output_token_count: 10000`. It derives midpoint-per-token values from that basis, multiplies those values by the session's accumulated assistant output tokens, and caches estimates in memory for the current Pi session.

## Known issues

Supported provider mappings are intentionally conservative: `openai`, `anthropic`, `mistral`/`mistralai`, `google`/`gemini`, `cohere`, and `huggingface` variants. OpenAI-compatible providers that are not actually OpenAI are treated as unsupported by default.

## Contributing

This project does not accept issues or pull requests. Create your own fork.
