pi-provimux
Use your AI API keys in Pi through Provimux or CLIProxyAPI. With Provimux, see which service answered and share published prices and cache lifetimes with pi-cache-keeper when available.
Package details
Install pi-provimux from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-provimux- Package
pi-provimux- Version
105.0.10- Published
- Nov 29, 2026
- Downloads
- 1,886/mo · 1,886/wk
- Author
- gnvoicu
- License
- MIT
- Types
- extension
- Size
- 344.4 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-provimux
Provimux's extension for Pi. It adds Provimux, one self-hosted, OpenAI-compatible endpoint for your AI API keys, as a provider in Pi, and works the same with plain CLIProxyAPI.
Every model your Provimux or CLIProxyAPI serves appears in Pi's /model, under the provider provimux. With
Provimux's Serve only my names
on (Provimux v8.1.3-pmx.2 or newer), /model shows only the names you chose, once the list is read again (when Pi
starts, or with /provimux-refresh). With Provimux, each model's name also says which of your API keys serve it
(Anthropic api, fallback OpenRouter api), the footer names the service that answered (answered: OpenRouter api),
and pi-cache-keeper can get the published prices and cache lifetimes of what answered, when available. With CLIProxyAPI, those parts stay quiet and everything else works.
pi install npm:pi-provimux
Then, in Pi:
/login Provimux
and enter the server's address (for example http://127.0.0.1:8317) and your client key.
pi-provimux is a fork of router-for-me/pi-cliproxyapi-provider, see Credits.
Commands
| Command | What it does | When you would use it |
|---|---|---|
/login Provimux |
Connects Pi to your server: asks for its address and key, checks that the server answers its model list with them, and loads its models. | The first time, or when the server's address or key changes. |
/provimux-refresh |
Reloads the model list from your server, with the accounts behind each model where the server lists them, and the prices and cache lifetimes it gives for what they answered as. | You added or removed a model, an account or a priority on the server, and Pi is still running. |
/fast |
Turns Fast mode on or off, saved for later starts: asks the server for its priority service tier on Provimux models whose entry lists a service tier, which can cost more. | You want quicker answers and accept that they may cost more. |
/ultrafast |
Turns Ultra Fast mode on or off, saved for later starts: asks the server for its Ultra Fast service tier on Provimux models whose entry lists a service tier. | You want the fastest tier the server offers for the model. |
/pause |
Holds each new model request Pi sends, in every Pi window with pi-provimux that shares your ~/.pi/agent, until you type /continue. |
You need Pi to stop sending for a while, for example while you change something on the server. |
/continue |
Lets the held requests go out again. | After /pause. |
/provimux-route |
Shows which of your accounts this conversation is on, whether that is a fallback, and whether a higher-priority route is free; /provimux-route release moves it back, after saying what that may cost and asking. |
A conversation fell back to another key (a shorter cache, a higher price) and you want it on the first one again. |
Not to confuse with pi-cache-keeper's refresh: /provimux-refresh
reloads your server's model list and, where the server lists them, the accounts behind each model; /cache-keeper-refresh fetches providers.dev's
prices and cache lifetimes again. Neither changes which account answers: your server decides that.
/login Provimux
What it does. It connects Pi to your Provimux (or CLIProxyAPI) server. It asks for the server's address and its
client key, and asks the server for its model list with them. If the server answers (an empty list is accepted), the
login is saved and the models are loaded into /model. It does not try a request to a model.
/login provimux (the provider id) does the same: Pi ignores case.
Example. You type /login Provimux. Pi shows:
Set up Provimux: enter the address of your Provimux or CLIProxyAPI server, then its client key. Give the address as host:port, for example http://127.0.0.1:8317.
Provimux server URL (Enter keeps http://127.0.0.1:8317):
Provimux client key (the API key your server accepts from Pi):
Checking the address and the key: asking the server for its model list...
If the server does not answer, or refuses the key, you see Could not log in with this address and key: … and
Enter the address and the key again., and the two questions come back.
What it changes, and for how long. Every later session that uses the same ~/.pi/agent: the address and the key
are saved in ~/.pi/agent/provimux.json and in Pi's auth.json, and the model list is saved for the next start.
Where PROVIMUX_BASE_URL or PROVIMUX_API_KEY is set, the model list is loaded with it instead; requests to the
models still use the address and the key of this login.
What it does not do. It does not choose a model: pick one in /model. If Pi first asks how to sign in, choose
Sign in with an account: the API-key way saves only the key, in auth.json, and after a restart Pi does not use
it for Provimux, so it says Provider is not configured: provimux (see
Login-style setup). Pi's /logout removes the login from auth.json only, not
provimux.json.
/provimux-refresh
What it does. It asks your server for its model list again, now, and updates /model: models added on the server
appear, and models it no longer lists are removed at once. Where the server lists its accounts (Provimux does), it
also reads again which accounts serve each model, so the names in /model (Claude Opus 5.5 · Anthropic api, fallback OpenRouter api) and what other extensions are told follow the server. From a Provimux that gives them, it also reads the
prices and cache lifetimes again. A change of priorities on the server reaches the routes other extensions are told
only here (or in a new session). Where the server lists no accounts, or that lookup fails, the names in /model come
without them.
Example. You type /provimux-refresh. Pi shows:
Reloaded 42 Provimux models from http://127.0.0.1:8317/v1/models?client_version=pi. /model shows the new list.
If the reload fails: Could not reload the Provimux models: …. Check that the server is running, or type /login Provimux to change its address or key.
With no key set up at all (no login, no apiKey in provimux.json, no PROVIMUX_API_KEY): Provimux has no key set up (no login, no apiKey in provimux.json, no PROVIMUX_API_KEY), so there is no model list to reload. Type /login Provimux (or /login provimux) and enter your server's address and key.
What it changes, and for how long. The model list, in this Pi and in the saved list (provimux-models.json) the
next start begins with. When Provimux has a key, each start also reloads the list by itself: with a saved list for
the same address and modes, Pi starts with it and reloads from the server in the background; without one, it first
loads the list from the server. There, unlike here, a model the server stops listing is kept for a while (Pi says so if it is the model
you use), in case it is gone only for a moment.
What it does not do. It does not change your server or which account answers, and it does not switch you to
another model; but if the server no longer lists the model you use, that model is no longer offered in /model. It does not
take an address or key: use /login Provimux for that. More: Model cache.
/fast and /ultrafast
What they do. They ask the server for a faster service tier: /fast for the priority tier, /ultrafast for the
Ultra Fast one. Only Provimux models whose server entry lists a service tier (any one) and that are not sent in
Claude's own format are asked, for the tier of the command typed; on the others nothing changes. How fast an answer comes and what it costs is the server's to decide. The same command again turns the mode
off; the other command switches to it directly.
Example. With a model whose entry lists a service tier, you type /fast. Pi shows fast in yellow beside the model's name in the
footer, and:
Fast mode is on, saved for later starts: requests to gpt-5.6-sol ask the server for its priority service tier, which can cost more. Type /fast again to turn it off.
Then /ultrafast reads Ultra Fast mode is on, saved for later starts (in place of Fast mode): …, and /ultrafast again
reads Ultra Fast mode is off, saved for later starts: requests no longer ask for a faster service tier. On a Provimux model that is
not asked: Fast mode is on, saved for later starts, but the current model (claude-opus-5-5) is not asked for a tier (its server entry lists none, or it is sent in Claude's own format), so its requests stay as they are. It applies to the Provimux models whose server entry lists a service tier, except those sent in Claude's own format. Type /fast again to turn it off. On another provider's model it says that the model is not a Provimux model.
What it changes, and for how long. This Pi window, all its sessions, and every later start that uses the same
~/.pi/agent: the choice is saved as fast in provimux.json, until you type the command again. Other Pi windows
already open keep their own until they load the extension again (a restart, /reload, a new or resumed session).
PROVIMUX_FAST set at start wins over the saved choice. If the model list (which carries the prices) can't be
reloaded, the mode is turned back in this window and the command says whether the saved setting was put back too. The prices Pi counts with change to the mode's
prices where models.dev has them.
What they do not do. They do not switch you to another model, and they do nothing on Claude models sent in Claude's own format. More: Fast and Ultra Fast modes.
/pause and /continue
What they do. /pause holds each new request Pi is about to send to a model, whatever its provider, until you
type /continue (another extension's own requests that bypass Pi's request hook are not held). A held request waits:
the window holding it checks the setting about every 0.2 seconds, and once the setting says requests continue, it
lets the request go. A request held in a window you close is never sent, and the pause does not keep anything waiting across a restart.
Example. You type /pause. Pi shows:
Requests are paused: each new request Pi sends to a model waits until you type /continue, in every Pi window with pi-provimux that shares this agent folder, also after a restart. An answer already streaming is not stopped.
While a window's request guard believes requests are paused, its footer says paused · /continue in the warning
colour (paused alone in a terminal narrower than 60 columns); with a Provimux model selected, the model's name in the
footer also ends with paused, in orange. Both come from that one belief. A window knows it from its start, at once when you type /pause or /continue in it, and each time its guard checks
the setting, which is when a request is about to go out and while one is held. An idle window keeps what its guard
last saw until its next check: after another window pauses, one that last saw no pause shows nothing until its next
request is held, and then shows the mark; after another window continues, one that last saw a pause keeps both signs
until its next request goes out.
Then /continue: Requests continue: each window holding a request checks about every 0.2 seconds and then lets it go. /continue
with nothing paused: Requests were not paused. /pause twice: Requests were already paused. Type /continue to let them go.
What it changes, and for how long. Every Pi window that has pi-provimux and the same ~/.pi/agent, also after a
restart: the pause is saved as pause in provimux.json, and each window reads it before each request. It lasts until
/continue in any window, or until provimux.json stops saying so (changed by hand, or removed: a window that finds
no provimux.json sends its requests).
What they do not do. /pause does not stop an answer already streaming or cancel anything: a paused Pi simply
waits, and the footer says why. Pi puts every extension's status on one line, in the order of their names, and cuts
it at the right edge, so in a narrow terminal the statuses of other extensions before it can push paused out of
view. More: Pausing provider requests.
/provimux-route
What it does. Shows which of your accounts this conversation is on, and moves it back to a higher-priority one
when that is free again. One model can be served by several of your accounts, tried by priority. When the first is
cooling down, Provimux sends the conversation to the next, and with session affinity on
(routing.session-affinity: true) the conversation stays bound there. /provimux-route asks your server, afresh at
every call, and shows:
- which account the conversation is on, in the words of the model names (
Anthropic api,OpenRouter api), and since when; - whether that is a fallback, and from which account, since it was bound there (a release or an automatic return starts that history again);
- whether a higher-priority route is free now or, if not, when the first of them is expected free;
- whether your server's automatic return is on (below).
The check sends nothing to a model and costs nothing. It works at any time, also while Pi is answering, and in Pi's RPC mode. It offers the release only where the release would go ahead: in the TUI, with a higher-priority route free.
/provimux-route release moves the conversation back, in Pi's interactive terminal and while Pi is not answering:
- It first says what the move may cost and asks. The conversation's next message may read the whole conversation once without cache: in tokens and, where Pi has the model's price, in dollars at list price for that size. Without a yes nothing is released.
- With a yes, Provimux removes the binding the check saw, and the next message goes to the first available route by priority. Where the conversation may be on a Codex WebSocket, that socket is closed, so the next message is routed afresh.
- When the current account is listed, it releases nothing unless a higher-priority route is free (it says when one is expected). It releases nothing when the conversation is already on a first route, while Pi is answering (type it again when the answer is done), or when the binding changed since the check (it shows the conversation as it is now).
- If the release was sent but its answer was lost or could not be read, it says whether it was released is not
known;
/provimux-routeshows where the conversation is. - In RPC mode it releases nothing and says so. In print and JSON mode the command sends nothing and says so on stderr.
- Known limit: a turn that starts between the last idle check and the closing of the socket can overlap the release;
/provimux-routeshows where the conversation ended up.
Automatic return. From Provimux 8.1.7-pmx.5 the operator can set routing.session-affinity-return.cold-after
so that the server moves a conversation back by itself. While that rule is in effect the show says, for example with
cold-after: 6m:
Automatic return: on. Once no request of this conversation has been routed for 6 minutes (a keep-warm request counts), Provimux can send its next request to a free higher-priority route; a pinned Codex follow-up stays on its account.
Otherwise, including where the server leaves the rule off (a cold-after at or above the binding's lifetime, or
rebind-on: never), it says Automatic return: off on this server.
Needs Provimux 8.1.7-pmx.4 or newer, with session affinity on. With an older Provimux, or plain CLIProxyAPI, it
prints This server has no conversation routes: /provimux-route needs Provimux 8.1.7-pmx.4 or newer (plain CLIProxyAPI has none). Update Provimux to use it; everything else works as before.
and changes nothing. A model whose name contains :: cannot be shown: Provimux answers that it has not seen the
conversation.
Example. Your conversation on claude-opus-5-5 fell back from your Anthropic key to your OpenRouter key. You type
/provimux-route. Pi shows:
Route of this conversation on claude-opus-5-5, as Provimux says now (this check sends nothing to a model and costs nothing):
• Now on: OpenRouter api, since 09:35 (40 minutes ago).
• A fallback: it was on Anthropic api until 09:35.
• No higher-priority route is free yet: one is expected free at 10:40 (in 25 minutes).
• Automatic return: off on this server.
To check again later: /provimux-route.
After 10:40 it says A higher-priority route is free now: Anthropic api. and
To move it now: /provimux-route release (it says what that may cost and asks first). You type
/provimux-route release. Pi asks:
Move this conversation from OpenRouter api to Anthropic api now?
Its next message may read the whole conversation once without cache (about 182,000 tokens, about $0.55 at the list price; more where the vendor also charges for writing the new cache). Staying costs a cached read, about $0.05 a message, while the cache is warm.
On yes: Released: this conversation is no longer bound to OpenRouter api. Its next message goes to the first available route (now: Anthropic api), and may read the whole conversation once without cache.
On no: Nothing was released.
What it changes, and for how long. Only your server's binding of this conversation for the current model, once: the next message goes to the first available route, and from then on the conversation is routed as usual. The check changes nothing. Nothing is saved in Pi.
What it does not do. It does not send a message, end a cooldown or choose an account: Provimux chooses, by priority. It moves only this conversation, for the current model, and not its sub-agents. It sees a conversation only once your key has used it since the server last started.
When you update pi-provimux to this version. Pi now names each conversation on a Claude-format model by its session
id (x-session-affinity, see Claude Messages format), where before Provimux recognised it
by the start of its content. So, with session affinity on, a conversation already running is bound afresh once for
each model it uses, at its first message on that model after the update: that message is routed as a new
conversation's. It may go to the account it was on, with its cache, or to another one, where it may read the whole
conversation once without cache. Until that message, /provimux-route says Provimux has no record of the conversation. Conversations
started after the update are not affected.
Resume, compaction, fork. What names the conversation is Pi's session id, and Pi keeps it or makes a new one:
- Resume (
--continue,--resume,/resume,--session) and moving in/tree: the same session, the same id. Provimux finds the same binding while it lasts (by default an hour without a request). With automatic return on, its next request can go to a higher-priority route, as any request of the conversation can. - Compaction (
/compact, or automatic): the conversation keeps its id. The summary request Pi sends to make the compaction carries no session id and is routed apart; the next turn is routed as usual. - Fork (
/fork,/clone,--fork): a new session with a new id, so a new conversation for Provimux, bound at the first route that is free./provimux-routein the fork says it has no record of it until its first message. /new: a new id, a new conversation.
What it does
From the original extension:
- Your models in pi. It reads the model list from
{root}/v1/models?client_version=piand registers each model with its context window, reasoning levels and, when models.dev knows it, its price. - Setup by
/login./login Provimuxasks for the address and the key, checks them, and saves them. - A model cache, so Pi starts at once when the server is slow;
/provimux-refreshreloads the list. /fastand/ultrafast: faster service tiers on the models that offer them./pauseand/continue: hold every request to the provider until you continue.- GPT prompt caching kept: a
gpt-request always starts with its base prompt as a developer message, so the prompt cache keeps being read. - Thinking level changes that keep the cache, for models that support them: Pi's own, placed as OpenAI documents.
- Elapsed time and tokens per second in Pi's footer.
- A fresh Codex WebSocket after compaction, so the server's context matches the compacted one.
Added in pi-provimux:
- Claude Messages format. Claude models go to
/v1/messagesin Claude's own format, automatically where safe. With Pi's long cache retention, that brings Anthropic's 1-hour prompt cache. - Where each model comes from, in its name. With Provimux, a model's
name ends with the keys that serve it:
Claude Opus 5.5 · Anthropic api, fallback OpenRouter api. - Where each model comes from, for other extensions. Over Pi's event bus, which accounts may serve each model and, with Provimux, which one answered each response, also over the Codex WebSocket. pi-cache-keeper uses it.
/provimux-route. Where this conversation is bound on Provimux, and back to a free higher-priority route, after saying what that may cost.- One package in Pi's list. The footer helper loads from the provider, so
pi listshows a single extension.
Install
# from npm
pi install npm:pi-provimux
# or from GitHub
pi install git:github.com/ngvoicu/pi-provimux
# from a local checkout
pi install /absolute/path/to/pi-provimux
# or temporarily for one run
pi -e /absolute/path/to/pi-provimux
The version names the original release it is built on, then a count of its own: 105.0.1 is pi-provimux's first release on the original's 1.5.0 (major × 100 + minor, then patch), 105.0.2 its second, and 105.1.1 would be the first on the original's 1.5.1.
Versions on npm are published from this repository's main by GitHub Actions, with npm provenance. A workflow
follows the original's releases: once a day old, one that merges cleanly and passes every check is merged into main
and released, with no person in between: this is switched on. docs/FOLLOWING.md says how, and
what that accepts.
It needs Pi 1.6.0 or newer.
Login-style setup (recommended)
This plugin needs both baseUrl and apiKey. Pi's built-in /login only supports multi-field prompts on the account/OAuth path, so Provimux appears under Sign in with an account.
When provimux.json or PROVIMUX_API_KEY already holds a key and no account login is stored, Pi also offers Sign in with an API key. Do not use it: it stores only the key, in auth.json, and after a restart Pi does not use that key for Provimux (with a login stored, the extension sets Provimux up for account logins only). The next start says Provider is not configured: provimux, and a saved default or a resumed session moves to another provider if you have one. Use Sign in with an account, or put apiKey and baseUrl in provimux.json. If you already used it, remove the provimux entry from auth.json (/logout) and log in with an account.
Which key wins. The extension reads the address and the key from the PROVIMUX_* variables first, then provimux.json, then the login in auth.json (see Resolution order). So a key in provimux.json wins over a key saved by a later /login that does not rewrite the file, as the API-key login does not. The account login writes its address and key into provimux.json as well, so after it the two agree. Change the key or the proxy with an account /login. If you change them in provimux.json or the environment while an account login is stored, the model list follows the new values but requests still carry the stored login's key: run /login again, or remove the provimux entry from auth.json.
Preferred: /login shortcuts
/login Provimux
or, by the provider id:
/login provimux
(Pi ignores case, so both name the same provider.) These shortcuts jump straight into the multi-field baseUrl + API key prompts, unless Pi also offers the API-key method (above): then it asks which one first, and you choose Sign in with an account.
Menu path
/login
Then choose:
- Sign in with an account (required for multi-field baseUrl + API key prompts)
- Provimux
- Enter:
- base URL — preferred form is host:port, e.g.
http://127.0.0.1:8317 - API key
- base URL — preferred form is host:port, e.g.
Final login validation calls {root}/v1/models?client_version=pi (this always bypasses the model cache and forces a fresh remote query):
- HTTP 200 → login succeeds (empty model list is still OK) and the model cache is rewritten
- non-200 / network error → login fails and you are prompted to re-enter base URL + API key
On success:
- models are registered immediately in the current session (0 models is allowed)
baseUrl/apiKeyare written to~/.pi/agent/provimux.json- Pi also stores the returned credential in
~/.pi/agent/auth.json
Re-run /login Provimux or /login provimux anytime to reconfigure. The built-in /logout command only removes credentials saved in auth.json; it does not erase provimux.json. Remove or update that file if you also need to clear the provider configuration.
Non-interactive configuration
You can still configure without /login.
Config file
~/.pi/agent/provimux.json:
{
"baseUrl": "http://127.0.0.1:8317",
"apiKey": "12345",
"fast": false,
"pause": false
}
Optional fields:
| Field | Default | Description |
|---|---|---|
baseUrl |
http://127.0.0.1:8317 |
Provimux or CLIProxyAPI address |
apiKey |
(required unless set via /login or env) | Bearer token / CPA API key |
providerId |
provimux |
Provider id shown in /model (written here by /login) |
providerName |
Provimux |
Display name in /login and UI (written here by /login) |
fast |
false |
Persisted speed preference: false (off), true (Fast), or "ultrafast" (Ultra Fast) |
pause |
false |
Persisted request-pause preference; provider requests wait until it is cleared |
tps |
true |
Show the elapsed time footer and TPS summary in the TUI; see Elapsed time and TPS |
answered |
true |
Show in the footer which route answered the last turn; see Which route answered, in the footer |
claudeMessages |
"auto" |
When Claude models use Claude's own format: "auto", true (always) or false (never); see Claude Messages format |
Environment overrides
| Variable | Overrides |
|---|---|
PROVIMUX_BASE_URL |
baseUrl |
PROVIMUX_API_KEY |
apiKey |
PROVIMUX_PROVIDER_ID |
providerId |
PROVIMUX_PROVIDER_NAME |
providerName |
PROVIMUX_FAST |
fast (true / false, also accepts 1, 0, yes, no, on, off) |
PROVIMUX_CLAUDE_MESSAGES |
claudeMessages (auto, or the same values as PROVIMUX_FAST) |
Resolution order for connection settings:
- Environment variables
provimux.json/logincredentials inauth.json- Default baseUrl
http://127.0.0.1:8317
At startup, PROVIMUX_FAST overrides the persisted speed preference: a true value selects Fast, and a false value turns both modes off. The variable does not accept ultrafast. If unset, the provider uses fast from provimux.json, or defaults to off.
baseUrl normalization
Preferred form is host:port only:
| Input | Inference baseUrl | Models URL |
|---|---|---|
http://127.0.0.1:8317 |
http://127.0.0.1:8317/backend-api/ |
http://127.0.0.1:8317/v1/models?client_version=pi |
http://127.0.0.1:8317/backend-api |
http://127.0.0.1:8317/backend-api/ |
same models URL |
http://127.0.0.1:8317/v1 |
http://127.0.0.1:8317/backend-api/ |
same models URL |
127.0.0.1:8317 |
http://127.0.0.1:8317/backend-api/ |
same models URL |
Pi then sends inference traffic to {inference}/codex/responses.
Fast and Ultra Fast modes
Both modes are off by default. They request faster processing for supported models and may use more credits or incur higher costs.
| Command | Model status label | Request field |
|---|---|---|
/fast |
fast |
service_tier: "priority" |
/ultrafast |
Ultra Fast |
service_tier: "ultrafast" |
The modes are mutually exclusive. Run the active command again to turn it off, or run the other command to switch directly. Each change saves the global preference in ~/.pi/agent/provimux.json and refreshes the provider's model pricing. The saved preference is restored at the next startup unless PROVIMUX_FAST overrides it.
Both modes apply only to models whose CLIProxyAPI catalog entry has a non-empty service_tiers array. The provider ignores additional_speed_tiers. When a mode is effective, Pi appends its yellow label to the bottom-right model status, and the command says what it turned on or off. On unsupported models, the commands still update the global preference and warn when enabling a mode, but the request and model status remain unchanged.
Both modes are independent of Pi's reasoning level and use experimental.modes.fast.cost from models.dev when available. Otherwise, the registered model uses the standard price; the plugin does not guess prices from -pro or -fast model IDs.
Pausing provider requests
Pause provider requests with:
/pause
Use /continue to clear the pause:
/continue
The pause holds each request Pi sends to a model through its request hook, whatever the provider. While a window's request guard believes requests are paused, that window's footer says paused · /continue (paused under 60 columns), from the same state as the orange paused beside a Provimux model's name. Both commands persist the pause boolean in ~/.pi/agent/provimux.json. Before every provider request, the extension rereads this setting. When it is true, the request waits asynchronously and checks again every 200 ms until /continue sets it to false. A pause issued during an active run lets that run finish before Elapsed stops; a run that starts while paused excludes its waiting time from Elapsed and TPS.
Model cache
The provider keeps a separate cache file so startup stays fast when CLIProxyAPI is slow or briefly unreachable:
~/.pi/agent/provimux-models.json
The cache stores only model metadata and derived endpoint URLs — the model list, Fast-capable IDs, inferenceBaseUrl, modelsUrl, and a fetchedAt timestamp. It never stores your API key or other credentials.
| Property | Value |
|---|---|
| Cache file | ~/.pi/agent/provimux-models.json |
| Remote query timeout | 60 seconds |
| Scope | tied to the current baseUrl (a different base URL ignores the existing cache) |
Startup / resume behavior
When the provider loads (including session resume):
- If a cache exists for the configured
baseUrl, its models are registered immediately. A remote query to{root}/v1/models?client_version=pithen runs in the background; on success, the cache is rewritten and the registered model list is refreshed. If the query fails, the existing cache remains active. - If no matching cache exists, the remote query runs synchronously. On success, the cache is written and the fetched models are registered. If it fails, startup logs a warning and no models are registered until the proxy responds.
Use /provimux-refresh to force an immediate remote refresh of the model catalog.
Refresh commands
/provimux-refresh— force an immediate remote refresh of the model catalog, rewrite the cache, and update registered models. Use this after adding or removing models on the proxy without restarting Pi./login Provimux//login provimux— re-entering credentials always forces a fresh models query and rewrites the cache.
Delete ~/.pi/agent/provimux-models.json to clear the cache manually.
Model mapping
From CPA catalog entry → Pi model:
| CPA field | Pi field |
|---|---|
slug |
id |
display_name |
name, followed by where the model comes from when CLIProxyAPI says |
context_window |
contextWindow |
input_modalities |
input (text / image) |
supported_reasoning_levels[].effort |
thinkingLevelMap + reasoning |
supports_reasoning_effort_updates |
compat.supportsMidConvoEffort |
visibility: "hide" |
skipped |
Unsupported Pi thinking levels are set to null so they are hidden in the UI. A level the model lacks asked on the command line of a one-shot run (pi -p --thinking low, --model provimux/<model>:low, or --models provimux/<model>:low when that pattern selects the model; also --mode json) is refused: nothing is sent, the error names the levels the model has, and Pi exits with 1. The flags are read as Pi reads them: a suffix that is part of a model's id (--model provimux/local-assistant:high, for a model listed as local-assistant:high) asks for no level. Elsewhere (the level picker, a saved default level, --thinking in an interactive or RPC session) Pi moves the level to the nearest one the model has, and the request names that level, never the missing one. When available, prices are matched against canonical model entries in models.dev; cost.tiers[].tier.size becomes Pi's inputTokensAbove, including thresholds such as 272000. The legacy context_over_200k field is used only when no explicit tiers are present. Ambiguous reseller prices are not selected arbitrarily and fall back to zero. These are catalog/list prices, not a guarantee of CPA's own markup or billing.
GPT Responses prompt caching
Pi builds no top-level instructions: it puts the system prompt, as given, in a leading
{ "role": "developer", "content": "…" } input item, for every model, and the provider sends that as Pi built it.
For gpt- model IDs (ignoring case and surrounding whitespace) the provider makes sure the request starts with a base
prompt: when the final body has instructions (an extension's before_provider_request hook set them), their text
becomes the leading developer message instead; when the input does not start with a developer message (no system
prompt, or a hook put another item first), You are a helpful assistant. is put in front as one. Existing input items
stay in order, tools and prompt_cache_key are unchanged, and other models keep their request shape. This applies
to HTTP and WebSocket requests, including Pi background streams that use this provider. A changed developer prefix or
model sends the full input instead of a WebSocket continuation delta. To drop or replace the base prompt, a hook
removes or changes that first item.
Cache-preserving thinking level changes
Models whose catalog entry sets supports_reasoning_effort_updates (GPT-6 on CLIProxyAPI) get Pi's cache-preserving mid-session thinking level changes, with placement following the OpenAI documentation: the effort of the first turn becomes the fixed request-level reasoning.effort, and each later change is carried by a configuration_update input item placed immediately before the user message it applies to, so switching levels mid-session keeps the prompt prefix — and the upstream prompt cache — intact instead of rewriting it. WebSocket previous_response_id continuation also survives level changes. Pi's Codex adapter carries these changes itself; the provider only moves the items to the placement above. Pi records the level it sent on each reply, none with thinking off.
The raw models.dev response is cached for 24 hours at ~/.pi/agent/tmp/models-dev-cache.json. A fresh cache avoids the network request; an expired cache is refreshed with a three-second timeout, and stale data is retained if refresh fails. If neither the network nor a previous cache is available, pricing safely falls back to zero. A small explicit alias table covers known CLIProxyAPI variants such as gemini-pro-agent → gemini-3.1-pro-preview; unknown variants are not guessed.
Claude Messages format
Claude models can be sent in Claude's own format to CLIProxyAPI's /v1/messages, using Pi's built-in Anthropic client,
instead of the Codex Responses format every other model uses. This happens automatically; nothing needs configuring.
- Which models: those CLIProxyAPI lists with
owned_by: "anthropic"(from its plain/v1/models) that Pi's built-in catalog also knows, and for which CLIProxyAPI reports an output limit (max_tokens). Their compat flags and thinking levels come from that catalog. Every other model, Claude models Pi doesn't know, and Claude models without a reported output limit stay on the Codex format. - Setting:
claudeMessagesinprovimux.json(orPROVIMUX_CLAUDE_MESSAGES) is"auto"by default.falsekeeps every model on the Codex format;truealso switches Claude models CLIProxyAPI reports no output limit for (they then get Pi's 16,384 default, see below). - Why: Claude's format can carry Anthropic features the Codex format can't. The main one is the 1-hour cache:
with
PI_CACHE_RETENTION=long, Pi marks the prompt withcache_controlttl: "1h", CLIProxyAPI passes it through, and Anthropic writes the 1-hour tier, on API keys too. One-hour cache writes cost 2× the input price instead of 1.25×. The thinking levels offered are also the model's own, not a generic list. - Limits come from CLIProxyAPI: the context window and output limit are what CLIProxyAPI reports, as for every
other model. Unlike the Codex format, Claude's format sends the output limit (
max_tokens) on every request. In"auto", a Claude model CLIProxyAPI reports no output limit for stays on the Codex format, which sends no output limit; withtruePi would fall back to 16,384 output tokens. - Not available for these models: Fast mode (a Codex service tier; they keep their standard price under
/fastand/ultrafast) and the Codex WebSocket transport. Thinking, tools, images and auto-compaction work as before. - Changing the setting refreshes the model list (the cache records it). The first request of an ongoing session after a model switches formats is a cache miss.
- The conversation is named: each turn carries the Pi session's id in
x-session-affinity, as the Codex format carries it insession-id, so Provimux binds the conversation by that id (and/provimux-routecan find it) instead of by the start of its content. The summary request of a compaction carries none. The header goes to your server only: Provimux itself does not pass it on to the vendor. A conversation already running when you update to a version that sends it is bound afresh once for each model, at its next message on it: that message is routed as a new conversation's, and may read the conversation once without cache.
Where each model comes from, in its name
Through CLIProxyAPI Pi sees one provider, so its model list does not say which of your API keys (or logins) serves a
model, nor whose. Provimux, or a CLIProxyAPI that lists its credentials
(router-for-me/CLIProxyAPI#7634), is asked for them with the
plain model list (GET /v1/models?include=accounts, one request per model list refresh), and each model's name then
ends with where it comes from:
Claude Opus 5.5 · Anthropic api, fallback OpenRouter api
GPT-6.1 Terra · OpenAI api
anthropic/claude-opus-5.5 · OpenRouter api
apiis an API key; a login shows assub(see Logins).- First comes what CLIProxyAPI may answer with: the credentials at the highest priority, joined by
orwhen they differ (Anthropic api or OpenRouter api). Afterfallbackcome the others, highest priority first: what may answer when the first fail or cool down. A service is named again only when it changes. - The service is the one behind CLIProxyAPI's provider (
claudeis Anthropic,codexis OpenAI …). An API key goes by the host CLIProxyAPI names for it (openrouter.aiis OpenRouter whatever the entry is called; a host that is not known is shown as it is). A provider that is not known keeps CLIProxyAPI's name for it. - Everything is read from CLIProxyAPI's list; nothing is guessed from a model's id or owner. A CLIProxyAPI that does not list its credentials, or a list that can't be read, leaves every name as it was.
- It says what the list said when it was fetched: after changing credentials or priorities in CLIProxyAPI, run
/provimux-refresh(the startup refresh also updates it). What answered a given request is a separate matter: see the next section.
Pi shows a model's name in /model beside its id and searches it, and its model patterns (--model, scoped models)
also match names: openrouter now matches every model that comes from OpenRouter, not only ids that contain the
word.
Which route answered, in the footer
Provimux can serve one model name through several routes (your Anthropic or OpenAI key, OpenRouter, any login …). After each answer on a Provimux model, the footer says which one answered it, in the words of the model names:
answered: Anthropic api
answered: OpenRouter api
answered: OpenAI api
It only ever shows the route that produced the answer you see.
- It is read from the answer itself: the
X-CPA-AUTH-*response headers, or on the Codex WebSocket thecpa_auth_*fields of the turn'sresponse.created. No other extension is needed. - When Pi tries a request again (an HTTP 429, or a Codex WebSocket continuation replayed on a fresh socket), only what the attempt that answered said counts: an attempt that names nobody is unnamed, whatever an earlier one said.
- Only an answer changes it: a turn that completed (or calls tools) with something in it. A failed, aborted or empty turn leaves it as it was.
- Whatever routes an install has and however it orders them, the footer names the one that answered: the credential list and its priorities play no part, and a route that is not in the list is named all the same.
- Only the session's own turns count: Pi's cache warmer and other extensions' requests, which can run at the same time, never change it.
answered: unknown: the proxy names answers (its model list lists credentials, as Provimux's does; a lookup of the list that fails changes nothing), but not this one (Provimux leaves an answer unnamed when plugin code took part in it).- Needs Provimux 8.1.1-pmx.1 or newer for the footer: an answer counts as named only with both its kind and its
provider (
X-CPA-AUTH-KINDandX-CPA-AUTH-PROVIDER), which Provimux sends from that version on. - Nothing from a proxy that names no answer (plain CLIProxyAPI), and nothing while a model of another provider is selected or answers, even for a Provimux answer that ends after the switch.
Set "answered": false in ~/.pi/agent/provimux.json to turn it off (takes effect on the next start or
/reload).
What really answered, for pi-cache-keeper
With pi-cache-keeper, after a fallback the footer names the cache
lifetime and the price of what really answered, instead of "unknown". Say your Anthropic key is rate-limited and your
server sends the request on to an OpenRouter key: the footer shows OpenRouter's lifetime and price. A name you set
yourself (opus) gets them too, once it has answered.
What this release does not do.
- It shows no countdown for what answered yet; pi-cache-keeper's countdown is the same as before.
- It does not change when the cache is kept warm.
- Pi's own total for a turn still uses the model's listed price.
How it works. From Provimux 8.1.7-pmx.5 on, each answer from Provimux names its
providers.dev entry (except through an account it reaches over an upstream WebSocket; see
Limitations). That is the model it really sent, at the provider it really sent it to
(X-Provimux-Entry; on the Codex WebSocket, provimux_entry in the turn's response.created). Behind your name
claude-fable-5-2 it can be anthropic/claude-fable-5-2 (your Anthropic key) or
openrouter/anthropic/claude-fable-5.2 (an OpenRouter key). Provimux's model list gives each entry's price, cache
lifetimes, input window and output limit.
pi-provimux reads that list at the start and on /provimux-refresh, as before. When an answer names an entry it does
not hold yet, it reads the list once more, for the values only: the routes stay as they were until /provimux-refresh.
It never reads the list once per answer. It hands each answer's entry, and the list's values, on to other extensions
(for other extensions).
When nothing changes.
- With a server that names no entries (Provimux before 8.1.7-pmx.5, or CLIProxyAPI), the requests, the names, the prices and what other extensions are told are as before, except for this version's other changes (see the CHANGELOG): Claude-format requests carry the session id, and after a Codex WebSocket replay other extensions are told the attempt that answered.
- pi-provimux prices nothing new and registers no new model: the models in
/modeland their prices are as before. - An answer that names its account but no entry has no values. Nothing is taken from the model's name or the kind of account.
Limitations.
- An account that Provimux reaches over an upstream WebSocket (a Codex or xAI account with
websockets: true) names no entry, so its answers carry no values. - When the list could not be read at Pi's start, no values are handed on until
/provimux-refreshor a new session, as with the routes.
Where each model comes from (for other extensions)
Through CLIProxyAPI Pi sees one provider, but each model is served by one of your API keys (or a login) at some
provider, and they can differ in window, prompt-cache lifetime and price (an Anthropic key keeps a cache for 5 minutes
by default; an OpenRouter key bills at OpenRouter's prices). This package tells other Pi extensions where each model comes from, over Pi's event
bus (pi.events), so that they need to know nothing about CLIProxyAPI.
pi-cache-keeper uses it to fill windows, cache lifetimes and prices
from providers.dev.
model-upstreams:request: an extension that wants the routes sends this (any payload). This package then asks CLIProxyAPIGET /v1/models?include=accountsagain and answers. Without such an extension this adds no request; the model list itself is always loaded with?include=accounts, for the names and the Claude Messages format. The answer belongs to the session that asked: when it ends (quit,/reload, another session) before the list arrives, the lookup is aborted and nothing is said.model-upstreams:{ provider, models: { [modelId]: { upstreams, fallbacks? } } }, the answer, and again after/provimux-refresh.upstreamsare what may serve the model (several: it is not known which),fallbackswhat may answer when those fail or cool down.model-upstreams:answered(Provimux):{ provider, model, upstreams }, what answered a request, at most once per answer.modelis the model the request was sent to (a virtual model's routed model, not the selection). Over HTTP and SSE only the response headers count: the kind inX-CPA-AUTH-KIND, the credential's provider inX-CPA-AUTH-PROVIDERand an API key's host inX-CPA-AUTH-HOST; fields in the body are not Provimux's (an inner gateway's) and are ignored. Over the Codex WebSocket, which has no response headers per turn, only thecpa_auth_kind,cpa_auth_providerandcpa_auth_hostfields Provimux puts on the turn'sresponse.created.- With the provider,
upstreamsis that one credential, whatever its priority, read from the response alone: its provider (whatever its letter case), its kind, and its host, where no host means the credential has none. The credential list is not consulted (it may be older than the proxy's state) nor waited for. Two credentials of different providers serving the same model are told apart. A credential that leads to a service not known is still named, so a change of route is seen: by its host for an API key that has one (api.example.test), else by its provider as the response gives it. - Needs Provimux 8.1.1-pmx.1 or newer, which sends the provider with the kind. A kind without a provider names nobody (below).
upstreams: []: answered, by something the proxy would not name. Provimux leaves an answer without the three when plugin code took part in its bytes; from a proxy that names answers (it lists its credentials, or named an answer before in this session) such an answer is reported as[], so that a listener does not keep the last named credential's values. Read it as "route not known". Whether the proxy names answers is known only once its credential list has loaded or it has named one: an answer that names nobody while the list is still loading and before anything was named in this session is not reported. A list that could not be read counts as still loading.- Nothing from plain CLIProxyAPI, which names no answer, nor before an extension asked for the routes.
- When: as soon as the answer's headers (or its
response.createdevent) arrive and its stream's first event says which model it is for, so before the answer ends, while the request is still out. - Each request on its own. Requests overlap: Pi's cache warmer refreshes the cache while the turn it warms is still streaming, and an extension can send its own request with the session's callbacks. Each request keeps its own response headers and its one report, so an answer is never reported with another request's credential or model.
pi-cache-keeper reads
upstreams: []as "route not known".- With the provider,
From a Provimux that names each answer's providers.dev entry (Provimux 8.1.7-pmx.5), and only from one:
model-upstreams:answered-entry:{ provider, model, entry, account? }, told just before an answer'smodel-upstreams:answered.entryis the entry the answer named (nullwhere it named its account but no entry);accountis Provimux's marker of the account that answered.model-upstreams:answereditself carries no entry.model-upstreamsalso carriesfigures: Provimux's object as it gave it (state,dataset_version,generated_at,fetched_at, andentries: entry →price,cache,input_window,max_output; contract 1, US dollars per million tokens, seconds, tokens). When a list read brought by an answer finds other values, the event is told again with the same routes as last told and the newfigures. The routes are as before.- Readers that know none of this (pi-cache-keeper 0.10.8) read every event as before.
An attempt tried again (a Codex WebSocket replay after the gateway lost the previous response, an HTTP retry):
model-upstreams:answeredis told for each attempt that names its route, so the last one told is the attempt that answered, as the footer shows.
An upstream is { provider, model?, subscription?, unmapped? }: the Pi provider the model would come from if used
directly (anthropic, openai-codex, openai, meta, openrouter, google) or a providers.dev provider Pi has none
for (devin, antigravity); the model's id there when it differs; true for a subscription login, false for an API
key, absent when not known. unmapped: true (only in model-upstreams:answered) marks an answer from a credential
that leads to a service not known: provider is then not a Pi or providers.dev id but the name the proxy gave (an API
key's host, else its provider name), and no providers.dev entry exists under it. A reader that does not know the field
can ignore it.
How the routes are made:
- Provimux, or a CLIProxyAPI that lists its credentials (router-for-me/CLIProxyAPI#7634):
CLIProxyAPI uses the highest priority that is free in every routing mode and picks among the credentials sharing it
(round-robin by default; with no priority set, all share 0). So the
upstreamsare the credentials at the highest priority, thefallbacksthe others. An API key whose host CLIProxyAPI names goes by the host (openrouter.ai,api.openai.com,api.anthropic.com,generativelanguage.googleapis.com,api.x.ai,api.meta.ai,api.kimi.com,api.moonshot.ai,api.moonshot.cn,api.deepseek.com,api.mistral.ai,api.groq.com,api.cerebras.ai,api.fireworks.ai,api.together.ai,integrate.api.nvidia.com,api.xiaomimimo.com; another host is not known), whatever its entry is called; without a host, an OpenAI-compatible entry counts as OpenRouter only when namedopenrouter. The model id is the provider's own, as Pi's catalog has it (the session's models, else the catalog pi-ai is built with): a prefix before it (CLIProxyAPI's own, or one configured for the credential) is left out unless what is left is not in the catalog and the id with it is. Soopenai/gpt-oss-120bat Groq stays as it is, and a prefixopenaibefore Groq'sllama-3.3-70b-versatileis left out;Qwen/Qwen3.6-Plusat Together,google/gemma-3-12b-itat NVIDIA,accounts/fireworks/models/…at Fireworks andlab/modelat OpenRouter are kept whole. A model the catalog does not have keeps as many parts as nearly all the provider's ids have, else its last. A credential at the top that leads somewhere not known makes the route not known (upstreams: []). - A CLIProxyAPI that doesn't: the lab its model list names as the owner (
owned_by), by login or key (subscriptionabsent; for OpenAI the Codex login or an OpenAI key);devin/…(CLIProxyAPI's own prefix) is Devin; any other name with a slash is not known.
Elapsed time and TPS (TUI)
The provider extension also loads extensions/tps.ts (so Pi lists the package as a single extension), which only activates for the primary interactive TUI session (ctx.hasUI && ctx.mode === "tui"):
- While the agent is running, the footer shows
Elapsed …(updates every second). - When the agent settles, the footer keeps the final elapsed time and a notification reports approximate TPS plus token usage (
out/in/ cache r/w / total). - Subagent and print-mode sessions do not own the timer, clear the parent footer, or emit TPS toasts.
Set "tps": false in ~/.pi/agent/provimux.json to turn off just this helper (takes effect on the next start or /reload).
Failure behavior
- CLIProxyAPI
closed network connectionresponses are normalized as transient network errors so Pi's agent-level retry policy reconnects and restarts the interrupted assistant turn. Completed conversation and tool results remain available; token streaming does not resume from the exact interruption point. - Before setup / without credentials: provider still appears in
/login; no models are listed yet. - After successful
/login: models are registered; credentials are stored inauth.jsonand mirrored toprovimux.json. - The built-in
/logoutcommand removes only the matchingauth.jsoncredential; environment variables andprovimux.jsonare unchanged. - If a models request returns HTTP 401 or CPA is unreachable during startup, an existing matching cache remains in use while the background refresh fails. Only when no cache is available is a warning logged; reconfigure via
/login Provimuxor fix config/env. - Login final step validates credentials by requesting models:
- HTTP 200 (including empty catalog) → credentials are persisted
- non-200 / network / invalid baseUrl → nothing is persisted; re-enter baseUrl + API key
- If CPA returns HTTP 200 with zero usable models: login still succeeds; re-run
/login Provimuxlater after models become available. - If the selected model does not provide a non-empty
service_tiersarray: the request is left unchanged;/fastand/ultrafaststill update the global preference and warn when enabling a mode. - After
/compact, threshold compaction, or overflow recovery, the provider closes the reused Codex WebSocket for the current session. CLIProxyAPI binds server-side context to the connection, so a reused socket would keep reporting a near-fullcacheReadand retrigger proactive compaction even though the client context is now small. SSE is unaffected because it bills from the request body.
Subscription logins
Provimux can also use a subscription login you own; whether a provider allows that is set by its terms, and you are responsible for following them.
Reference: Logins.
Credits
pi-provimux is a fork of pi-cliproxyapi-provider by Router-For.ME, released under the MIT license. Nearly everything it does is their work: the provider, the login, the model mapping, the cache, the Fast modes and the Codex stream. pi-provimux adds the Provimux parts above and merges the original's changes. Thank you to router-for-me for the extension and for CLIProxyAPI.
License
MIT. See LICENSE.