Web search for Pi.
Citations included.
pi-mimo-search registers a regular
web_search tool in
Pi, backed by the
Xiaomi MiMo Web Search plugin (pay-as-you-go). Every call returns
an answer, numbered source citations and the exact cost it just incurred —
while your conversation stays on whatever provider you like, Token Plan included:
the search is a side-call, not a provider switch.
Why
A search tool that
shows its receipts.
MiMo offers web search only as a server-side plugin on its OpenAI-compatible API. This package exposes it to Pi as a plain agent tool — and keeps everything the plugin returns that a naive integration would drop.
Works with any main model
The search is a side-call to MiMo's PAYG endpoint. Your conversation can stay on a Token Plan model, Claude, anything — web search being PAYG-only never blocks you.
Structured citations
url_citation annotations are parsed and returned — title, site, publish time,
summary — as typed structuredContent, not dropped by stream
normalization.
Cost visibility
Every call prints its own cost line — plugin fee in CNY, tokens in USD — and returns the same numbers structurally, folded into Pi's session usage so you can reconcile against the MiMo console.
Cost controls
max_keyword: 1 by default — each keyword is one billed
invocation — with capped limit, thinking disabled, and
mimo-v2.6-flash for the side-call.
Intent recognition by default
The search model decides whether a live search is needed. News, prices, weather, releases — searched; questions answerable from memory — skipped, so idle conversation costs nothing.
Actionable errors
401 (key), 402 (balance), the webSearchEnabled gate and 429 each come back
with the exact fix — no status-code archaeology.
How it works
One tool call.
Two providers.
The model calls the tool
Ask about anything live — or force it when the model is too confident. The tool description teaches the model when search is appropriate.
Side-call to MiMo
The payload goes to api.xiaomimimo.com/v1 with your PAYG
sk-… key: flash model, thinking off, one keyword, capped page count.
Your main conversation never moves.
Answer + citations parsed
The response's annotations become numbered citations with title, site and
publish time — attached as structuredContent alongside the rendered
answer.
Cost lands in your session
The one-line cost summary prints under the answer, and the same numbers fold into Pi's session usage — reconcilable with the billing console, not folklore.
Auth comes from Pi
Stored /login xiaomi credential first, XIAOMI_API_KEY env
fallback. The extension never reads key material itself.
Programmatic results
Codemode scripts and other callers get the full JSON — answer, citations, token usage and cost — directly from the tool result.
Parameters
Three knobs, all capped.
Everything that can spend money has a conservative default and a hard ceiling.
| parameter | meaning |
|---|---|
| query | search query in the user's language — one well-formed query beats several narrow ones |
| force : bool | default false — force_search: search even if the model thinks it knows the answer |
| maxKeyword : 1-3 | default 1 — concurrent keywords per round, each is one billed invocation |
| results : 1-5 | default 2 — pages returned and injected; more pages = more input tokens |
What a call returns
structuredContent carries the full result:
The model-facing content is the answer plus the source list plus the
one-line cost summary.
Billing
About two cents a search.
The plugin fee is charged separately from tokens and separately from Token Plan quota — both visible on every call, so nothing surprises you at month end.
Plugin fee per invocation (CN region; USD 5 / 1,000 overseas). One round fires up to
max_keyword concurrent searches = that many invocations.
Typical call: max_keyword: 1 — the fee plus a few hundred flash-model
tokens charged to your PAYG balance.
Searches per CNY 50 of balance. The tool prints its cost line per call so session totals stay reconcilable with the billing console.
When it fails
Every error names its fix.
| symptom | fix |
|---|---|
| 401 | /login xiaomi with the sk-… key, or export XIAOMI_API_KEY (exact name) |
| 402 | insufficient PAYG balance — top up at the console's Account Balance page |
| webSearchEnabled false | activate the plugin at Plugin Management and wait ~5 minutes (server-side cache) |
| 429 | rate limit — retry with backoff |
| no web_search tool | package missing or disabled — pi list to check, pi config to enable, restart Pi |
| answers without searching | intent mode said "not needed" — ask again with force: true |
PAYG-only, verified
Web search is gated off on token-plan-* endpoints regardless of plugin
activation — webSearchEnabled stays false. That is exactly why this tool
uses a sk- key on api.xiaomimimo.com as a
side-call: your main model can keep its Token Plan.
The key must be the pay-as-you-go format sk-… — a
tp-… Token Plan key will not work.
Install
Five steps to a live search.
Steps 1-2 happen in the MiMo console: create a PAYG sk-… key, top up
(CNY 10 is plenty for ~600 searches) and activate the Web Search Plugin. Then:
1. Give Pi the key
stored in auth.json (mode 600)
2. Install the package
or from GitHub, then /reload
3. Verify the tool
expect web_search in the output
| alternative | purpose |
|---|---|
| git install | pi install git:github.com/rioliu/pi-mimo-search — straight from the repository |
| XIAOMI_API_KEY | env fallback for headless/CI setups — exact name matters, e.g. in ~/.zshrc |
| npm test | 12 unit tests, plain Node, no dependencies — fixture from a real API response |
Try it
Open Pi and ask anything that needs current information — roughly CNY 0.02 for the first live search:
Source, tests and the full README live at
github.com/rioliu/pi-mimo-search
· MIT licensed.