Pi
Connect Pi, the minimal terminal coding agent, to GreenPT Code via its OpenAI Chat Completions-compatible endpoint — and see what's already open before you install anything.
Pi (source: earendil-works/pi) is a minimal, extensible terminal coding agent. Its unified LLM layer talks to any provider through ~/.pi/agent/models.json — including plain OpenAI Chat Completions endpoints — so GreenPT connects directly with no translation proxy.
We're evaluating Pi as a GreenPT-friendly coding tool
If you run into issues following this guide, contact us.
What's already open, before you install anything
You don't need an API key, Pi, or a config file to read GreenPT's own onboarding material — some of it is served publicly, unauthenticated, straight off the wire:
| Request | What it gives you |
|---|---|
GET /v1/agents | A public markdown intro to the API — agents, capabilities, run usage, billing, and curl examples — whenever the request has no Authorization header. |
GET /v1/pricing | Current model prices, no key required. |
GET /v1/skills/catalog | The list of platform skills (name + one-line description), including greenpt. |
GET /v1/skills/catalog/greenpt | The full instruction body of the greenpt skill — the same guidance below on driving the API and setting up the status footer — as plain text. |
curl -s https://api.greenpt.ai/v1/agents
curl -s https://api.greenpt.ai/v1/pricing
curl -s https://api.greenpt.ai/v1/skills/catalog
curl -s https://api.greenpt.ai/v1/skills/catalog/greenptThat last one is worth pulling up first: it's a self-contained walkthrough you
can read before deciding whether to set anything up. The same content is also
injectable into a real conversation — any authenticated chat completion can
add "skills": "greenpt" to its request body to get it applied as a system
prompt, so an agent operating on your behalf can pull in this guidance without
you pasting it in by hand.
None of this makes a completion for you — you still need a GreenPT API key for that — but it means the "how do I use this" step has no signup wall.
Prerequisites
-
Pi installed:
npm install -g --ignore-scripts @earendil-works/pi-coding-agent # or curl -fsSL https://pi.dev/install.sh | sh -
A GreenPT API key: manage API keys
1. Set your API key
echo 'export GREENPT_API_KEY="your-greenpt-key"' >> ~/.zshrc # or ~/.bashrc
source ~/.zshrc2. Add the GreenPT provider
Add a greenpt provider to Pi's custom model config, ~/.pi/agent/models.json:
{
"providers": {
"greenpt": {
"baseUrl": "https://api.greenpt.ai/v1",
"api": "openai-completions",
"apiKey": "$GREENPT_API_KEY",
"models": [
{ "id": "deepseek-v4-flash-0731" },
{ "id": "glm-5.2" },
{ "id": "kimi-k3" }
]
}
}
}This file reloads every time you open /model — edit it during a session, no restart needed.
Keep the $ on $GREENPT_API_KEY — without it, Pi reads the text as a
literal key instead of an environment variable.
Recommended models
glm-5.2z.aiFlagshipNewGreenPT Code flagship coding model with strong reasoning, agentic tool-use, and multi-file software engineering performance. See the GreenPT Code guide for IDE setup. Also available as output-compression variants (glm-5.2-caveman, -honey, -ponytail) at the same price.
Use it for: The default. Agentic, multi-file work across a large codebase.
kimi-k3Moonshot AINewMoonshot Kimi K3, an open-weight 2.8T-parameter native multimodal agentic model with hybrid reasoning for long-horizon coding, knowledge work, and reasoning.
Use it for: The hardest refactors and long-horizon agent runs.
deepseek-v4-flash-0731DeepSeekNewDeepSeek V4 Flash, 2026-07-31 snapshot. A fast, low-cost reasoning model with a 1M-token context window and tool use. Reasoning is always on, so allow enough output budget for it.
Use it for: Routine edits and test runs, at a fraction of the cost.
Any model from the catalogue works — add its id to the block above. See
Model Cards for the full list and prices.
Optional: keep the model list in sync
greenpt-pi-sync.sh rewrites only .providers.greenpt, cross-checking our
recommended coding models against what's live so a retired model drops out
instead of leaving a dead entry behind. Re-run it whenever you want a refresh.
curl -fsSL https://docs.greenpt.ai/scripts/greenpt-pi-sync.sh -o greenpt-pi-sync.sh
shasum -a 256 greenpt-pi-sync.sh # 9822dcb656ab1a36a4adf7b43549fd835d18ef28a64c657440a48ae97bb21ded
sh greenpt-pi-sync.shIt writes to ~/.pi/agent/models.json using credentials from your shell, so a
mismatched hash means the download was tampered with — don't run it. Set
GREENPT_BASE_URL to sync against a different environment.
3. Select the model
pi --provider greenpt --model glm-5.2Or start pi and run /model to choose interactively; greenpt appears as a
provider with your configured models underneath.
4. Verify the connection
Quick standalone check of the same endpoint Pi will call:
curl -s -H "Authorization: Bearer $GREENPT_API_KEY" -H 'Content-Type: application/json' \
"https://api.greenpt.ai/v1/chat/completions" \
-d '{"model":"glm-5.2","messages":[{"role":"user","content":"Reply with exactly: OK"}],"max_tokens":64}' \
| jq '.choices[0].message.content'If this returns "OK", Pi will connect the same way — fix auth or the base
URL here first before troubleshooting inside Pi.
Live status footer: green-meter
Pi's default footer squeezes everything into flat, run-on lines with no
label/value distinction. green-meter replaces it with labeled,
color-weighted groups, and — for the greenpt provider specifically — turns
the usual $ cost line into GreenPT's real signals: live credit spend and
environmental impact.
You're at: ~/Dev/ozan/studio-pi4 · on branch, main
Usage: ↑12k · ↓664 · Draw: €0.02/m · €1.30/h · €0.043 sess · Impact: 6.7 g/m · 160 g/h · 288.0 g sess · 1.49 kW
Session: started 12m ago · Context: 41.7% Model: deepseek (off)Draw— €/min, €/hour, and cumulative this session, from the live credit balance (X-Credits-RemainingonGET /v1/agents).Impact— CO₂e (per-minute, per-hour, session total) and averagekWpower draw, fromGET /v1/profile/impact.
Install it
Download and verify before placing the file — it's a Pi extension, which runs with the same trust as any other code you load into your terminal:
curl -fsSL https://docs.greenpt.ai/extensions/green-meter.ts -o green-meter.ts
shasum -a 256 green-meter.tsThe hash should be:
a998b478c1b0dddee625649003b528bce78eede110e390a07aa8d567cf2ab34f green-meter.tsRead it before you load it
A mismatched hash means the download was tampered with or corrupted — don't load it. It's under 600 lines of plain TypeScript with no dependencies beyond Pi's own extension API; worth a skim even with a matching hash.
Then place it where Pi auto-discovers extensions, and reload:
mkdir -p ~/.pi/agent/extensions
mv green-meter.ts ~/.pi/agent/extensions/green-meter.ts/reloadIt's enabled by default once loaded. Toggle it, or get an in-session summary, with:
/green-meter # off → restore Pi's default footer, on → re-enable
/green-meter help # what it shows and where the numbers come fromCaveats
- Whole-account figures. Both the credit balance and the impact endpoint
are keyed to your account, not this Pi session — another process spending
on the same key inflates
DrawandImpact. They're session-relative signals, not per-run meters. - Session-scoped, persisted across reloads. Values reset when you start a
new session, but survive a
/reloadof the same one. - GreenPT only. The
Draw/Impactgroups require thegreenptprovider; other providers fall back to Pi's native$cost line.
If you already have a GreenPT API key and just want this without reading the
rest of this page, GET /v1/skills/catalog/greenpt (see above)
carries the same install steps as agent-readable instructions — hand it to
your own coding agent and let it set this up for you.
Troubleshooting
| Symptom | Fix |
|---|---|
| 401 Unauthorized, key looks right | GREENPT_API_KEY is unset in the shell Pi runs from — check echo "len=${#GREENPT_API_KEY}" in that exact terminal, not just the one you exported it in |
| 401 Unauthorized, env var is set | Key/environment mismatch — a develop key against api.greenpt.ai (or a production key against develop.api.greenpt.ai) fails auth; match the key to the baseUrl |
| "Model not found" | The id in models.json must exactly match an entry from that environment's GET /v1/models — case and formatting matter |
Provider doesn't show up in /model | models.json reloads on /model open, not on a timer — confirm the file is valid JSON and the path is ~/.pi/agent/models.json |
contextWindow/maxTokens show defaults | GreenPT's /v1/models doesn't expose these — set them by hand per model or accept Pi's defaults (128000/16384) |
green-meter shows Cost: instead of Draw:/Impact: | The active model's provider isn't greenpt — switch with /model, or check models.json if greenpt itself doesn't appear |