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
/v1at the end. Pi adds/chat/completionsto it.A model ID exactly as
GET /v1/modelslists it, for examplez-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.
curl -fsSL https://pi.dev/install.sh | shpi --versionpowershell -c "irm https://pi.dev/install.ps1 | iex"pi --versionnpm install -g --ignore-scripts @earendil-works/pi-coding-agentThe 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
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
Add RealRelay.ai to models.json
Create
~/.pi/agent/models.json, or add therealrelayentry to theprovidersobject 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: falsemakes Pi send its instructions with the standardsystemrole. Many models on RealRelay.ai reject the newerdeveloperrole.contextWindowandmaxTokensdefault 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 usescontextWindowto decide when to compact the conversation.In the reasoning form,
supportsReasoningEffortlets Pi sendreasoning_effort, andthinkingLevelMapmakes thexhighandmaxlevels valid by sending them ashigh.To keep Pi's files somewhere other than
~/.pi/agent, setPI_CODING_AGENT_DIR.
Verify
- 1
Call the endpoint directly
Run this with your key. A JSON reply with a
choicesarray 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
Check that Pi sees the model
--list-modelsshould list your model underrealrelay. 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
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:
{ "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.
pi --provider realrelay --model "z-ai/glm-5.2" --thinking highWhich 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 thatREALRELAY_API_KEYis set in the terminal that started Pi, and thatmodels.jsonis 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.
baseUrlis missing/v1, or already ends in/chat/completions.400 mentioning the
developerrole. Add"supportsDeveloperRole": falseundercompat.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.
contextWindowis larger than the model's real limit. Lower it to the value on the model's catalog page.
