A collection of useful extensions for Pi Coding Agent – small, friendly add‑ons that make Pi even more helpful.
- Extensions live under
.pi/extensions/<extension-id>/. - Each extension must export a default async function from an
index.tsfile:export default async function (pi: ExtensionAPI) { /* … */ }
- Available extensions:
model-selector: A gentle, generalized model selector. It reads amodels.jsonfile in~/.pi/agent/, discovers the providers you’ve listed, fetches their available models, and registers them with Pi. After that you can use the /select‑model command to pick a provider and a model from a friendly UI.
- Read your configuration – it looks for
~/.pi/agent/models.json(or amodels.jsonin the project root) and parses the JSON. - Ask each provider – for every provider defined, it calls the provider’s
/v1/modelsendpoint to obtain a list of models. - Register with Pi – the discovered providers and their models become first‑class citizens inside Pi, so the rest of Pi (commands, UI, etc.) can treat them like built‑in models.
- Select a model – when you run the
/select‑modelcommand, Pi shows a list of providers, then a list of models for the chosen provider. Picking one instantly switches the session to that model.
{
"providers": {
"example-provider-1": {
"baseUrl": "http://localhost:1234",
"apiKey": "YOUR_API_KEY",
"maxContextLength": 200000 // optional, overrides default context window for this provider's models
},
"example-provider-2": {
"baseUrl": "http://your-host:port",
"apiKey": "YOUR_API_KEY"
}
}
}Place this file at ~/.pi/agent/models.json. The extension will automatically pick it up the next time Pi starts.
- Types – import
ExtensionAPIfrom@earendil-works/pi-coding-agentfor proper typing. - Verification – simply start Pi (
pi) and ensure your extension loads without errors. Use the interactive UI to test the/select‑modelcommand. - Documentation – each extension’s folder should contain its own
README.mdexplaining its purpose and usage. - Reference – consult the official Pi docs at the Pi Coding Agent GitHub Repository.
Copy the extension folder into one of the following locations so Pi can discover it:
.pi/extensions/– local to this repository (good for development)~/.pi/agent/extensions/– global location for all of your Pi projects
Once placed, restart Pi and you’ll see the new /select‑model command ready to use!
Below is a quick walk‑through of how the model‑selector extension looks and works inside Pi’s built‑in terminal UI (TUI).
- Open the Pi TUI (e.g., run
piin your terminal). You’ll see the usual chat area and a status bar at the bottom. - Trigger the command by typing the slash command:
The UI will pop up a selector dialog.
/select-model - Choose a provider – a list appears with the providers defined in your
models.jsonfile. Provider selection list (example):
- example-provider-1
- example-provider-2
- Pick a model – after selecting a provider, another list shows the models that were fetched from that provider’s
/v1/modelsendpoint. Model selection list (example):
- openai/gpt-4 (ID: openai/gpt-4)
- google/gemma-4-31b (ID: google/gemma-4-31b)
- Confirm – once you pick a model, Pi automatically switches to it and updates the status bar:
The status bar now reflects the active provider and model.
model: anav96-llama: bartowski/google_gemma-4-31B-it-GGUF:Q8_0
You can repeat the command at any time to switch to a different model.
Tip: If you don’t see any providers, double‑check that
~/.pi/agent/models.jsonexists and follows the documented format. After editing the file, reload Pi (/reloadcommand) to pick up the changes.
The extension now ships with an additional command:
/set-context-limit
Running this command opens a series of dialogs:
- Select a provider – pick the provider whose context window you want to change.
- Enter a new value – either choose a common size (64 k, 128 k, 256 k, 512 k) or type a custom number of tokens.
- The new value is written back to your
models.jsonfile and will be used for all models from that provider.
After setting the value, you can reload the session (/reload) and the updated context window will be reflected in the model selector UI.
Happy extending!