Use DeepSeek V4.1 Flash and GLM 5.3 Flash in Pi
Point Pi at OpenScale with one tested setup. Your existing Pi configuration stays yours.
Tested live with Pi 1.1.0: file edits, shell, reasoning and streaming.
Quick start
The fastest way to try it. Replace YOUR_OPENSCALE_API_KEY with your key and run it yourself; do not paste the key into an agent conversation. Paste this into your terminal.
node -e '
const fs=require("fs"),[f,p]=process.argv.slice(1),o=(v)=>v?.constructor===Object,id=(v)=>JSON.stringify(v?.id??v?.model??v)
const m=(a,b)=>{for(const k in b)a[k]=Array.isArray(b[k])?[...(Array.isArray(a[k])?a[k]:[]).filter((x)=>!b[k].some((y)=>id(y)===id(x))),...b[k]]:o(b[k])?m(o(a[k])?a[k]:{},b[k]):b[k];return a}
let c={};try{c=JSON.parse(fs.readFileSync(f,"utf8"))}catch(e){if(e.code!=="ENOENT")throw e}
fs.mkdirSync(require("path").dirname(f),{recursive:true});fs.writeFileSync(f,JSON.stringify(m(c,JSON.parse(p)),null,2)+"\n")
' ~/.pi/agent/models.json '{"providers":{"openscale":{"baseUrl":"https://api.openscale.so/anthropic","api":"anthropic-messages","apiKey":"YOUR_OPENSCALE_API_KEY","models":[{"id":"deepseek/deepseek-v4.1-flash","name":"DeepSeek V4.1 Flash","reasoning":true,"input":["text","image"],"contextWindow":1048568,"maxTokens":384000,"cost":{"input":0.06,"output":0.24,"cacheRead":0.003,"cacheWrite":0.06}},{"id":"z-ai/glm-5.3-flash","name":"GLM 5.3 Flash","reasoning":true,"input":["text","image"],"contextWindow":1048576,"maxTokens":131072,"cost":{"input":0.12,"output":0.4,"cacheRead":0.024,"cacheWrite":0.12}}]}}}'
pi --provider openscale --model deepseek/deepseek-v4.1-flash
- Protocol
- Anthropic Messages
- Base URL
https://api.openscale.so/anthropic
Keep it in Pi's config
Uses the custom provider schema of Pi 1.x (npm package @earendil-works/pi-coding-agent) with api: "anthropic-messages". Check pi --version first.
Merge the provider configuration
Default path:
~/.pi/agent/models.json.Merge providers.openscale into the active models.json. Respect PI_CODING_AGENT_DIR. Keep other providers and model overrides.
This is a merge fragment, not a replacement for an existing file. Model metadata is generated from OpenScale's catalog; prices are estimates in USD per million tokens, not an account balance or billing receipt.
Download config fragment~/.pi/agent/models.json{ "providers": { "openscale": { "baseUrl": "https://api.openscale.so/anthropic", "api": "anthropic-messages", "apiKey": "$OPENSCALE_API_KEY", "models": [ { "id": "deepseek/deepseek-v4.1-flash", "name": "DeepSeek V4.1 Flash", "reasoning": true, "input": [ "text", "image" ], "contextWindow": 1048568, "maxTokens": 384000, "cost": { "input": 0.06, "output": 0.24, "cacheRead": 0.003, "cacheWrite": 0.06 } }, { "id": "z-ai/glm-5.3-flash", "name": "GLM 5.3 Flash", "reasoning": true, "input": [ "text", "image" ], "contextWindow": 1048576, "maxTokens": 131072, "cost": { "input": 0.12, "output": 0.4, "cacheRead": 0.024, "cacheWrite": 0.12 } } ] } } }Authenticate locally
The file reads the key from OPENSCALE_API_KEY in the environment that launches Pi; $OPENSCALE_API_KEY is a variable reference, not the key. A literal key also works.
Never paste your key into an agent conversation.
Select and verify
Use /model to reload the model file, or reopen Pi.
Start pi --provider openscale --model deepseek/deepseek-v4.1-flash, or choose it with /model. Set defaultProvider and defaultModel in ~/.pi/agent/settings.json to make it the default.
Official Pi documentation
Models and prices
Prices are USD per 1M tokens. You pay only for the tokens you use, and new accounts get free credit to try it.
| Model | Input | Cached input | Output |
|---|---|---|---|
| DeepSeek V4.1 Flashdeepseek/deepseek-v4.1-flash | $0.06 | $0.003 | $0.24 |
| GLM 5.3 Flashz-ai/glm-5.3-flash | $0.12 | $0.024 | $0.40 |
The full catalog, with context windows and limits, is at api.openscale.so/v1/models.
Let your agent set it up
An agent that can fetch URLs and edit local files can do the setup for you. Paste this prompt into it.
Read https://openscale.so/setup.md and follow the Pi recipe to configure OpenScale on this machine. Preserve my existing configuration and verify the connection. Guide me through entering my API key locally if needed.- Confirm the requested agent and inspect its installed version and active configuration location. Read only the relevant settings; do not dump credential stores or unrelated environment variables. If the agent is not installed, link its official installation instructions and let the user choose installation.
- Read the matching recipe and its linked configuration. If the installed schema differs, consult the linked official docs for that version. Do not guess, silently upgrade, or apply a different version's schema.
- Back up any file you will edit with a unique timestamp and its existing permissions. Backups may contain secrets: keep them local and private. Merge only the OpenScale provider block with a format-aware editor. Preserve JSONC/JSON5/YAML/TOML comments, other providers, defaults, profiles, secrets and unrelated settings. Never overwrite the full file with a downloaded snippet. On reruns update the same provider, without duplicate keys. Preserve existing OpenScale customizations unless they conflict with the requested setup.
- Ask the user to create an account at https://openscale.so/signup?utm_source=agent_setup&utm_medium=agent, create an API key at https://app.openscale.so/app/keys, and ensure credits are available. Let them enter the key in the agent's local credential flow or private environment configuration. Never request the key in chat, print it, put it in shell history, commit it, or send it to any endpoint except https://api.openscale.so. Reuse an existing working credential without displaying it.
- Validate configuration syntax and use the agent's supported reload procedure. Select an OpenScale model for the test session; preserve the previous default unless the user explicitly requests changing it. Keep separate vision, audio and auxiliary provider settings unless the user asks to move them too.
- Fetch https://api.openscale.so/v1/models without authentication to confirm the chosen model ID exists. That checks discovery, not credentials or inference. Through the configured agent, send one short prompt: “Reply with OK.” Confirm the response and selected provider/model. For coding agents, also ask it to use one harmless read-only tool (for example, report the current directory) and answer after the tool result. Do not claim tool support from a text-only test. This small test uses account credits; do not run repeated benchmarks.
- Report the agent version, changed paths (no secrets), selected model, discovery result, inference result and tool result separately. If credentials or a restart are pending, say “configuration saved; connection not yet verified.” Do not report success from merely writing a file.
Troubleshooting and undo
- Missing models: check active profile, provider filters, model allowlists and overrides before changing unrelated settings.
- 401: re-enter the key locally. 402: check account credits. 404: check the base URL for the recipe's protocol and the exact live model ID. 429: respect Retry-After and retry with backoff. Do not loop indefinitely.
- Streaming or tool errors: record the agent version and a redacted error, and check that the agent uses the protocol and base URL its recipe states. Do not switch protocols on your own; each recipe names the one that was tested.
- Undo: remove only the OpenScale provider entries added by this setup and restore any selection changed for testing. If restoring a backup, first ensure it will not discard subsequent edits. Remove only credentials created for this setup using the agent's supported local auth flow.
Questions
Which models can I use in Pi with OpenScale?
This guide sets up DeepSeek V4.1 Flash (deepseek/deepseek-v4.1-flash) and GLM 5.3 Flash (z-ai/glm-5.3-flash). Every model in the catalog is listed at https://api.openscale.so/v1/models.
How much does Pi cost with OpenScale?
You pay per token, with no subscription needed. DeepSeek V4.1 Flash: $0.06 input, $0.003 cached input and $0.24 output per 1M tokens. GLM 5.3 Flash: $0.12 input, $0.024 cached input and $0.40 output per 1M tokens. New accounts get free credit to try it.
Which API does Pi use with OpenScale?
Anthropic Messages, at the base URL https://api.openscale.so/anthropic. One OpenScale API key works for every agent and protocol.
Has this Pi setup been tested?
Tested live with Pi 1.1.0: file edits, shell, reasoning and streaming.
How do I undo the setup?
Remove only the OpenScale provider entries added by this setup and restore any selection changed for testing. If restoring a backup, first ensure it will not discard subsequent edits. Remove only credentials created for this setup using the agent's supported local auth flow.

