pi-kunavo0.1.0
Kunavo provider extension for pi: Claude and GPT models through one Kunavo API key, with the model list, context windows and prices read from Kunavo's public 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
pi-kunavo
Kunavo as a provider in pi, the coding agent. Kunavo is an AI API gateway: Claude and GPT models behind one API key and one prepaid balance.
With this extension the models Kunavo sells show up in pi's /model list as
kunavo/<model id>, with their context windows, output limits and prices. The
list is read from Kunavo's public price list, so a model that goes on sale
appears in pi without a new release of this package.
- npm:
pi-kunavo - Needs: pi (
@earendil-works/pi-coding-agent; written for and tested with 1.7), and a Kunavo API key from https://kunavo.com/app/keys
Install
pi install npm:pi-kunavo
To try it for one run without adding it to your settings:
pi -e npm:pi-kunavo
Give pi your key
Either of these:
In pi, run
/login kunavoand paste the key. pi keeps it in its ownauth.json.Or set it in the environment before you start pi:
export KUNAVO_API_KEY=sk-kn-your-key
A key stored with /login is used before the variable. The extension never
reads the key: pi resolves it and sends it, and only to the API
(https://api.kunavo.com). The request for the model list carries no key.
Then pick a model with /model, or start pi on one:
pi --list-models kunavo
pi --model kunavo/<model id>
Where the models come from
From https://kunavo.com/pricing.json, the price list Kunavo publishes without a key: every model on sale, its limits and its listed prices. This package holds no model's name.
- Which models are listed. The chat models that take tool calls and stream their answers. Image, video and music models are sold by the task and are not listed in pi.
- When the list is read. The first time pi starts with the extension (pi
waits up to five seconds for it), and after that whenever pi refreshes its
model lists: after an interactive start, when
/modelopens, after a login, at most once in ten minutes. A list older than a day is read again before pi starts. - Where it is kept. In
pi-kunavo-models.jsonin pi's directory (~/.pi/agentunless you moved it), so pi starts without waiting on the network and still has the models when there is none. The file holds what the price list said and when; no key, nothing about your account. - Offline. With
--offlineorPI_OFFLINEset, no request is made and the saved list is used.
If the list cannot be read and none is saved, pi starts all the same, without
Kunavo models, and the reason is shown once. /reload tries again.
How requests are sent
- Claude models go to Kunavo's Anthropic Messages route. Prompt caching works there the way pi does it for Anthropic, and so does thinking.
- Every other chat model goes to the OpenAI-compatible Chat Completions route.
How a model takes thinking settings (which effort each of pi's thinking levels
sends, and whether thinking can be turned off at all) is taken from pi's own
catalog entry for the same model, so /thinking offers what the model accepts.
A Claude model newer than your pi is run with adaptive thinking that cannot be
switched off until pi is updated.
Requests carry pi's own User-Agent followed by pi-kunavo/<version>.
Prices pi shows
The cost pi prints beside a session is its own sum: the tokens it counted times the listed price per million, with the listed cache rates and, on the models that have one, the long-context rate. It is an estimate. What the wallet was charged is on https://kunavo.com/app/usage, and the prices themselves are on https://kunavo.com/pricing.
Good to know
The output limit and your balance. pi sends a model's output limit with every request, and Kunavo holds the cost of that limit on the wallet until the request is settled, then charges what was used. A request the wallet cannot cover is refused. So this extension asks for at most 32,000 output tokens a request, which is also what Kunavo holds for a request that names no limit, even where the model can write more. To let a model write longer answers, raise its
maxTokensin pi'smodels.json, up to the limit on https://kunavo.com/pricing; the hold grows with it, to a few dollars a request on the models with the highest output prices:{ "providers": { "kunavo": { "modelOverrides": { "<model id>": { "maxTokens": 64000 } } } } }Keeping a cache warm. pi can send small requests of its own to keep an idle prompt cache alive. The extension does not switch that on for Kunavo's models: every request is billed.
Pre-release Claude features. Message threads, per-message effort, mid-conversation tool changes and server-side fallback are left off. pi works without them.
Environment
| Variable | What it does |
|---|---|
KUNAVO_API_KEY |
Your key. Read by pi, not by the extension. |
KUNAVO_BASE_URL |
Sends requests somewhere other than https://api.kunavo.com: a gateway of your own, or a test stand-in. An origin (https://host) is taken as the gateway; a URL with a path is taken as the OpenAI-compatible base as written. |
KUNAVO_PRICING_URL |
Reads the model list from another address. For testing. |
A value that is not an http(s) URL is ignored, and pi says so once.
Development
npm install
npm run typecheck
npm test
The tests run against test/fixtures/pricing.json, the answer of
/pricing.json to Kunavo's catalog, and against the pi packages in
devDependencies. Nothing in them calls Kunavo.
To load a checkout into pi: pi -e /path/to/pi-kunavo.
License
MIT