Coding agents

Pi

Connect the Pi coding agent to RealRelay.ai as a custom provider in models.json: install it, add the provider, check the connection and choose models and thinking levels.

Protocol
OpenAI Chat Completions
Base URL
https://www.realrelay.ai/v1
Official docs
github.com
Checked against the tool’s docs
2026-10

Overview

Pi is a small, extensible coding agent for the terminal. It reads and edits files in your project and runs commands. You connect it to RealRelay.ai by adding a custom provider to its models.json file. That provider uses the OpenAI Chat Completions API (/v1/chat/completions).

  • An API key from the API keys page of the console.

  • The base URL with /v1 at the end. Pi adds /chat/completions to it.

  • A model ID exactly as GET /v1/models lists it, for example z-ai/glm-5.2. Pick one that supports tool calling.

Pi is developed in the earendil-works/pi repository. Oh My Pi is a separate project with its own config format; see the Oh My Pi guide.

Install

Use Pi's installer. It installs Node.js if needed, pins Pi's dependencies, and lets you update later with pi update.

macOS · Linux
curl -fsSL https://pi.dev/install.sh | shpi --version
Windows PowerShell
powershell -c "irm https://pi.dev/install.ps1 | iex"pi --version
npm (Node.js 22.19+)
npm install -g --ignore-scripts @earendil-works/pi-coding-agent

The npm route needs Node.js 22.19 or newer and does not pin Pi's dependencies.

If pi --version prints a version number, the install worked. If the command is not found, open a new terminal.

Configure

  1. 1

    Put the key in an environment variable

    The config file refers to the key by name, so the key itself stays out of the file. Replace sk-*** with your key.

    ~/.zshrc · ~/.bashrc
    export REALRELAY_API_KEY="sk-***"

    Run source ~/.zshrc, or open a new terminal, before starting Pi.

    Windows PowerShell
    [Environment]::SetEnvironmentVariable("REALRELAY_API_KEY", "sk-***", "User")

    Close and reopen the terminal before starting Pi.

  2. 2

    Add RealRelay.ai to models.json

    Create ~/.pi/agent/models.json, or add the realrelay entry to the providers object if the file already exists.

    ~/.pi/agent/models.json
    1{2  "$schema": "https://pi.dev/schemas/models.schema.json",3  "providers": {4    "realrelay": {5      "name": "RealRelay.ai",6      "baseUrl": "https://www.realrelay.ai/v1",7      "api": "openai-completions",8      "apiKey": "$REALRELAY_API_KEY",9      "compat": {10        "supportsDeveloperRole": false11      },12      "models": [13        {14          "id": "z-ai/glm-5.2",15          "contextWindow": 200000,16          "maxTokens": 3276817        }18      ]19    }20  }21}

    Use this form for a model that thinks before it answers, so Pi's thinking levels reach RealRelay.ai. All three reasoning settings are needed; with one missing, the level you pick is not sent.

    ~/.pi/agent/models.json
    1{2  "$schema": "https://pi.dev/schemas/models.schema.json",3  "providers": {4    "realrelay": {5      "name": "RealRelay.ai",6      "baseUrl": "https://www.realrelay.ai/v1",7      "api": "openai-completions",8      "apiKey": "$REALRELAY_API_KEY",9      "compat": {10        "supportsDeveloperRole": false,11        "supportsReasoningEffort": true12      },13      "models": [14        {15          "id": "z-ai/glm-5.2",16          "contextWindow": 200000,17          "maxTokens": 32768,18          "reasoning": true,19          "thinkingLevelMap": { "xhigh": "high", "max": "high" }20        }21      ]22    }23  }24}
  • "$REALRELAY_API_KEY" tells Pi to read the key from that variable when it sends a request. The variable must be set in the terminal that starts Pi.

  • supportsDeveloperRole: false makes Pi send its instructions with the standard system role. Many models on RealRelay.ai reject the newer developer role.

  • contextWindow and maxTokens default to 128,000 and 16,384. RealRelay.ai does not report a model's limits, so set them from its catalog page. Never set them higher than the real limit; Pi uses contextWindow to decide when to compact the conversation.

  • In the reasoning form, supportsReasoningEffort lets Pi send reasoning_effort, and thinkingLevelMap makes the xhigh and max levels valid by sending them as high.

  • To keep Pi's files somewhere other than ~/.pi/agent, set PI_CODING_AGENT_DIR.

Verify

  1. 1

    Call the endpoint directly

    Run this with your key. A JSON reply with a choices array means the address, key and model work.

    Terminal
    1curl -sS "https://www.realrelay.ai/v1/chat/completions" \2  -H "Authorization: Bearer sk-***" \3  -H "content-type: application/json" \4  -d '{"model": "z-ai/glm-5.2", "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with OK"}]}'
  2. 2

    Check that Pi sees the model

    --list-models should list your model under realrelay. The second command sends one prompt, prints the answer and exits.

    Terminal
    pi --list-models realrelaypi --provider realrelay --model "z-ai/glm-5.2" --print "Reply with OK"
  3. 3

    Start a session in a project

    Send a short message. A reply confirms the whole path, and the request appears in the console's usage logs.

    Terminal
    cd /path/to/your/projectpi --provider realrelay --model "z-ai/glm-5.2"

Models

Inside Pi, /model opens a searchable list. Press Ctrl+S on a model to make it the default for new sessions, and Ctrl+P cycles through models. Opening /model also reloads models.json, so edits show up without a restart.

Pi only offers the models you list under the provider. Add one entry per model, each with its own limits:

~/.pi/agent/models.json → providers.realrelay.models
{ "id": "z-ai/glm-5.2", "contextWindow": 200000, "maxTokens": 32768 },{ "id": "deepseek/deepseek-v4-pro", "contextWindow": 200000, "maxTokens": 32768 }

For a reasoning model, pick the level with /thinking in a session or --thinking on the command line. Pi only offers levels the model entry allows.

Terminal
pi --provider realrelay --model "z-ai/glm-5.2" --thinking high

Which models suit an agent is covered under Choosing a model.

Troubleshooting

  • The model does not appear in /model. Pi hides models whose provider has no usable key. Check that REALRELAY_API_KEY is set in the terminal that started Pi, and that models.json is valid JSON.

  • 401, or it works in one terminal only. The variable is missing in that terminal. Open a new terminal after editing your profile, or check echo $REALRELAY_API_KEY.

  • 404. baseUrl is missing /v1, or already ends in /chat/completions.

  • 400 mentioning the developer role. Add "supportsDeveloperRole": false under compat.

  • The thinking level seems to have no effect. One of the three reasoning settings is missing. Compare your entry with the reasoning form above.

  • 400 mentioning reasoning_effort. The model does not accept that field. Use the basic form for it, without the reasoning settings.

  • Context errors on long sessions. contextWindow is larger than the model's real limit. Lower it to the value on the model's catalog page.