A pi extension that adds a /models-refresh slash command.
When you run /models-refresh inside a pi session:
- Resolves the current provider. It reads the active model from the session
(
ctx.model) to get the provider id and its base URL, and pulls the provider's API key from pi's auth viactx.modelRegistry. - Calls
<baseUrl>/modelswithAuthorization: Bearer <apiKey>and reads the catalogue (handles{ data: [...] },{ models: [...] }, and bare arrays). - Converts to pi's format. Each entry becomes
{ id, name, input: ["text"], reasoning: <heuristic> }. Thereasoningflag is detected from id/name hints (e.g.*-reasoning,-r1,o1–o4,deepseek-reasoner, …). - Writes
~/.pi/agent/models.json. Only the current provider'smodelsarray is replaced; every other provider in the file is preserved, along with the provider'sname/api/baseUrl. - Reloads pi. It calls
ctx.modelRegistry.refresh(), which re-readsmodels.jsonfrom disk so the refreshed catalogue is available immediately in the running session.
The folder is already registered in ~/.pi/agent/settings.json:
{
"extensions": ["~/pi-models-refresh"]
}(Equivalent: drop this folder into ~/.pi/agent/extensions/ — pi auto-discovers
a directory with an index.ts.)
- Make sure a model is selected (so the provider/URL/key can be resolved).
- Run:
/models-refresh
- You'll get a notification with the number of models written. Use
/modelto pick one of the refreshed models.
- Heuristic metadata.
inputis always["text"]andreasoningis a best effort guess from the model id/name. Most/modelsendpoints (v1/models) only exposeid/object/owned_by, so pi can't derive context window, token limits, or pricing from them — those fields are left unset for pi to default. - Lots of models. The endpoint may return hundreds/thousands of entries (the OmniRoute gateway here returned ~1900). That is intentional — the command mirrors everything the provider exposes.
- If the provider uses OAuth instead of a plain API key,
getApiKeyForProviderstill resolves the current credential for the request.