@rakshazi/nodion0.3.0
Register Nodion as a Pi provider with a live model catalog
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
nodion: Nodion's models in Pi
Install with pi install npm:@rakshazi/nodion.
Nodion.com runs an OpenAI-compatible gateway at https://api.nodion.ai/v1. This extension registers it as a Pi provider, fills the catalog from the live model list, and can narrow the picker to the models Nodion marks as coding-plan compatible.
Auth
/login nodion stores an API key in Pi's active credential store. NODION_AI_KEY also configures the provider without a stored key.
The catalog call needs no key, but it sends a configured one anyway: a models.json base URL can point at a gateway that does.
Models
The catalog is read from GET /v1/models at interactive startup and persisted in models-store.json, so print mode, pi --list-models and an offline start use the last fetch.
- Only
kind: "chat"entries are registered; the endpoint also listsdecisionandembeddingsmodels. - A model with
is_ready: falseis skipped, because Nodion reports no healthy route for it right now, and joins the catalog again once a fetch reports it ready. - Prices arrive as USD-per-token decimal strings and are shown as USD per million tokens. Cache reads and writes keep their own rates; a model without a published cache price bills cache traffic at zero.
max_imagesbecomes the per-message image limit.- Thinking levels come from
reasoning_efforts. A model that lists no stages keepsmediumas its model default and offers no other level. A model that lists stages offersoffonly when Nodion accepts"none", since an effort outside the list is rejected.
Too many image inputs
Nodion can reject a request with 400: ... too many image inputs once the session holds more images than the model accepts. The run ends with the provider error as usual, and the extension shows a warning: the images read so far will be replaced with placeholder text in model context on the next user message, the prompt cache is broken, and that message replays roughly the estimated post-drop input token count. The warning also points at /compact for shrinking the session first.
On the next user message, every image before that message is replaced with [image omitted: Nodion rejected the session for too many image inputs], and a system reminder tells the model that earlier images were dropped, to re-read only the specific file it needs, at most two images in total, and to ask the user when it needs more. Images in the new message are kept. After the first completed turn, the replacement is written to the session as append-only context_edit entries, so later requests use it without re-transforming the message list.
The pending drop is stored as a nodion-image-drop marker on the branch and restored at session start. A failed or aborted run leaves it pending. A compaction re-evaluates the post-compaction projection: the drop stays pending with a fresh cutoff when image-bearing entries survive, and clears when none remain. Because the edit is append-only, re-reading a file brings that image back, and forking before the drop keeps the original branch; there is no un-drop command.
Coding plan only
Add this to the global settings.json (~/.pi/agent/settings.json):
"nodion": {
"coding_plan_only": true
}
Then /model and pi --list-models show only models whose catalog entry has coding_plan: true. Without the key, every chat model shows.
The value is read when the extension loads, so /reload or a new session applies an edit. A nodion section that is not an object, or a coding_plan_only that is not a boolean, falls back to every model and shows a warning at session start.
Provider routing
Nodion routes each request dynamically by price, latency and throughput, and normally keeps a session on one provider so its cache stays warm. If a provider has no capacity or is down, Nodion falls back to another and removes the failed provider from rotation until it recovers.
Nodion accepts an optional provider object on chat completions. The same keys are optional under nodion.provider; an absent block or key leaves the request unchanged.
"nodion": {
"coding_plan_only": true,
"provider": {
"only": ["provider-id"],
"ignore": ["another-provider-id"],
"sort": "latency",
"allow_fallbacks": false
}
}
only: provider ids to route to. One id withallow_fallbacks: falsepins requests to that provider; several ids let Nodion choose among them.ignore: provider ids to exclude from routing. Bothonlyandignoremay be set, and Nodion applies both.allow_fallbacks: whether Nodion may use a provider outsideonlywhen the listed ones cannot serve.falserefuses the fallback; omitting it leaves Nodion's normal fallback on.sort: the metric that orders the candidate routes.price: lowest prompt price first; when two routes tie on prompt price, the completion price decides.latency: lowest time to first token.throughput: highest throughput in tokens per second.priority: Nodion's default routing, the same as omittingsort.
If sort routes tie or lack enough metrics, as a new provider might, Nodion falls back to priority and then current load. Any other sort value returns a 400.
only and ignore entries are trimmed and de-duplicated. Copy the exact ids from Nodion's provider picker: the catalog exposes display names such as Verda and Munito, but those are not ids, and an unknown id makes every Nodion request fail with no backend matches the requested provider preferences until the setting is fixed and the extension reloaded.
provider: {}, an empty list, or a knob with a broken value sends no routing key for that knob, and a broken knob is reported at session start while the remaining knobs still apply. The block is read when the extension loads, so /reload or a new session applies an edit.
A providers.nodion.compat.openRouterRouting block in models.json reaches the same request field. When both are configured, nodion.provider wins.
Coding plan usage
The footer shows 5h … · wk … · mo … only while the active model's provider is nodion. The labels are dim, a number turns warning above 70% and error above 90%, a live 0% shows 0%, a value under 1% shows <1%, and an idle 5-hour window shows -.
/nodion opens a card with the plan name, status, wallet overage, 10-column meters, reset countdowns and local reset times. Press r to refresh and esc to close.
Data comes from GET /v1/plan with the stored key or NODION_AI_KEY. The call is free and limited to 60 requests per minute per key.
Refresh runs on session start, on a switch to a Nodion model, after a settled run at most once per 30 seconds, every 5 minutes while a Nodion model is active, and when r is pressed.
A 404 with no_coding_plan or coding_plan_ended clears the footer and shows the message in the card; a 401 clears it; a network or 5xx failure keeps the last good values.
A providers.nodion.baseUrl entry in models.json also directs the plan request, so the key stays on the configured gateway.
Refresh
Interactive startup refreshes the catalog. /model <term> refreshes when the term does not match a cached model id, and a plain /model opens the picker on the persisted list. The catalog still has no refresh command: start a new session to see a newly added model in the plain list. /nodion refreshes plan usage; the catalog keeps its own refresh path.
Behind a gateway
A providers.nodion.baseUrl entry in models.json points both chat requests and the catalog request at a compatible endpoint.
Tests
cd ~/.pi/agent/extensions/nodion && node --test catalog.test.ts options.test.ts routing.test.ts images.test.ts