Coding Tools
Pi Coding Agent
Connect Pi Coding Agent to TokenLab
Let my agent set this up
Copy this task to an agent already running on your computer:
Read this guide and help me connect Pi to TokenLab:
https://tokenlab.sh/docs/en/integrations/pi-coding-agent
Check my installed version and active configuration first.
Preserve existing accounts, providers, permissions and other settings.
Back up local files and show proposed changes.
Have me enter any API key locally; never ask for, print or paste it in chat.
Check configuration loading first.
Explain any paid request test separately before running it.Install and configure Pi
Use the current Pi installation instructions. The npm package is @earendil-works/pi-coding-agent. On Windows, follow the shell setup; the CLI uses Git Bash by default. Skip installation when Pi is already available.
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.85.1
pi --versionThe configuration below was checked with Pi 0.85.1. Other versions need their own verification against the official documentation.
Back up ~/.pi/agent/models.json, then append the tokenlab entry after existing entries inside providers; create the file only if it is absent. A nonempty PI_CODING_AGENT_DIR selects the directory containing models.json. Keep existing provider order, settings.json, accounts, default-model fields and permissions unchanged. If tokenlab already exists in the configuration or saved accounts, use another provider name and update the launch command. Set TOKENLAB_API_KEY in the launch environment using Quickstart for macOS, Linux, WSL or Windows PowerShell; never put the key in chat.
{
"providers": {
"tokenlab": {
"baseUrl": "https://api.tokenlab.sh/v1",
"api": "openai-completions",
"apiKey": "$TOKENLAB_API_KEY",
"models": [{ "id": "gpt-5.6-luna" }]
}
}
}The leading $ in "$TOKENLAB_API_KEY" is required: a bare "TOKENLAB_API_KEY" is a literal string. Choose a current model with Chat Completions and tool support. Set context, output, image and reasoning options from that model’s details instead of copying another model’s limits.
Optional: the reversible Pi setup helper provides preview, apply and original-file restoration with Python 3.11+. TokenLab Skills plugin 0.1.2 includes these scripts; a standalone Skill installation can also be used after updating to a version that contains them. For an existing plugin or standalone Skill installation, follow the README update instructions and confirm the script is present. The manual configuration here remains usable without the helper.
Check and restore
Use the same terminal and agent directory to check loading, then select TokenLab explicitly for this session. An unset TOKENLAB_API_KEY can hide the provider from the model list. Discovery proves registration and credential presence, not key validity or a completed API request.
pi --list-models tokenlab
pi --provider tokenlab --model gpt-5.6-lunaA prompt uses TokenLab balance. Check the reply and its request record before testing tools. To undo the manual configuration, remove only the provider entry you added, preserving all other settings and accounts.
Skills and MCP
Pi loads Skills natively. Install the TokenLab Skill for API integration guidance. MCP requires a separate Pi extension; do not paste an MCP client configuration into models.json.