GreenPT Docs
GreenPT Code

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:

RequestWhat it gives you
GET /v1/agentsA public markdown intro to the API — agents, capabilities, run usage, billing, and curl examples — whenever the request has no Authorization header.
GET /v1/pricingCurrent model prices, no key required.
GET /v1/skills/catalogThe list of platform skills (name + one-line description), including greenpt.
GET /v1/skills/catalog/greenptThe 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/greenpt

That 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 ~/.zshrc

2. 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": "glm-5.3" },
        { "id": "deepseek-v4.1-flash-1017" }
      ]
    }
  }
}

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.

Using Oh My Pi?

Oh My Pi, a fork of Pi, reads apiKey the other way round: write the bare name, "apiKey": "GREENPT_API_KEY". With the $, it sends the text $GREENPT_API_KEY as the key and every request fails with 400 Bad Request.

glm-5.3z.aiFlagship

The newest z.ai flagship reasoning model, successor to glm-5.2, with agentic tool-use at a lower price.

Input€1.10
Cached input€0.275
Output€4.40
Context1M
ReleasedAug 2026
ChatReasoningTool useAgentic coding

Use it for: The default: agentic, multi-file work across a large codebase.

deepseek-v4.1-flash-1017DeepSeekNew

The 17 October 2026 snapshot of DeepSeek V4.1 Flash: multimodal reasoning, tool calling and a 1M-token context window for chat and agentic coding.

Input€0.36
Cached input€0.04
Output€1.45
Context1M
ReleasedOct 2026
ChatReasoningVisionTool useLong context

Use it for: Routine edits, quick questions 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   # 0eefbddb07156e83d269f48fedfb2d6b01650b9276313b273dbaa39adaec5e4e
sh greenpt-pi-sync.sh

It 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.3

Or 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.3","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.

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-Remaining on GET /v1/agents).
  • Impact — CO₂e (per-minute, per-hour, session total) and average kW power draw, from GET /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.ts

The hash should be:

a998b478c1b0dddee625649003b528bce78eede110e390a07aa8d567cf2ab34f  green-meter.ts

Read 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
/reload

It'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 from

Caveats

  • 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 Draw and Impact. 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 /reload of the same one.
  • GreenPT only. The Draw/Impact groups require the greenpt provider; 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

SymptomFix
400 Bad Request on every requestThe environment variable was not read and the text $GREENPT_API_KEY went out as the key. Pi needs "$GREENPT_API_KEY"; Oh My Pi needs the bare name "GREENPT_API_KEY"
401 Unauthorized, key looks rightGREENPT_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 setKey/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 /modelmodels.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 defaultsGreenPT'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

On this page