MIT · Pi package · Xiaomi MiMo web search

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.

$ pi install npm:pi-mimo-search
web_search url citations cost per call any provider

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.

00

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.

> web_search: latest pi release notes, force=true
01

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.

model: mimo-v2.6-flash (thinking off) tools: [{type: web_search, max_keyword: 1, limit: 2, ...}]
02

Answer + citations parsed

The response's annotations become numbered citations with title, site and publish time — attached as structuredContent alongside the rendered answer.

{ answer, citations[], usage{..., pluginInvocations}, cost{tokensUsd, pluginFeeCny} }
03

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.

[search cost: CNY 0.0160 plugin fee + $0.00025 tokens = $0.00247 total]
04

Auth comes from Pi

Stored /login xiaomi credential first, XIAOMI_API_KEY env fallback. The extension never reads key material itself.

$ /login xiaomi # paste sk-... key stored in ~/.pi/agent/auth.json (600)
05

Programmatic results

Codemode scripts and other callers get the full JSON — answer, citations, token usage and cost — directly from the tool result.

structuredContent.citations[0].url structuredContent.cost.totalUsd

Parameters

Three knobs, all capped.

Everything that can spend money has a conservative default and a hard ceiling.

parametermeaning
querysearch query in the user's language — one well-formed query beats several narrow ones
force : booldefault false — force_search: search even if the model thinks it knows the answer
maxKeyword : 1-3default 1 — concurrent keywords per round, each is one billed invocation
results : 1-5default 2 — pages returned and injected; more pages = more input tokens

What a call returns

structuredContent carries the full result:

{ answer, citations: [{ url, title, siteName, publishTime, summary }], usage: { promptTokens, completionTokens, pluginInvocations, pages }, cost: { tokensUsd, pluginFeeCny, totalUsd } }

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.

CNY 16 / 1,000

Plugin fee per invocation (CN region; USD 5 / 1,000 overseas). One round fires up to max_keyword concurrent searches = that many invocations.

≈ CNY 0.02

Typical call: max_keyword: 1 — the fee plus a few hundred flash-model tokens charged to your PAYG balance.

3,000+

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.

symptomfix
401/login xiaomi with the sk-… key, or export XIAOMI_API_KEY (exact name)
402insufficient PAYG balance — top up at the console's Account Balance page
webSearchEnabled falseactivate the plugin at Plugin Management and wait ~5 minutes (server-side cache)
429rate limit — retry with backoff
no web_search toolpackage missing or disabled — pi list to check, pi config to enable, restart Pi
answers without searchingintent 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)

$ /login xiaomi

2. Install the package

or from GitHub, then /reload

$ pi install npm:pi-mimo-search

3. Verify the tool

expect web_search in the output

$ pi --print "Reply with exactly: TOOLS: <list>"
alternativepurpose
git installpi install git:github.com/rioliu/pi-mimo-search — straight from the repository
XIAOMI_API_KEYenv fallback for headless/CI setups — exact name matters, e.g. in ~/.zshrc
npm test12 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.