pi-mimo-web-search
Web search for Xiaomi MiMo models in Pi
Package details
Install pi-mimo-web-search from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-mimo-web-search- Package
pi-mimo-web-search- Version
1.0.2- Published
- Jul 1, 2026
- Downloads
- 301/mo · 301/wk
- Author
- jianjye
- License
- MIT
- Types
- extension
- Size
- 8.2 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
MiMo Web Search Extension for Pi
Enables web search for Xiaomi MiMo models in Pi by automatically injecting the web_search tool into every request.
What It Does
When you ask MiMo about current events, recent news, or anything that benefits from up-to-date information, the model will search the web and use the results to answer — just like it would through the MiMo web UI.
The extension hooks into Pi's before_provider_request event and injects the web_search tool into every outgoing request to a MiMo direct API provider. No manual configuration or keywords needed — the model decides when to search based on your query.
Prerequisites
MiMo direct API key — a pay-as-you-go key from api.xiaomimimo.com, not a token plan key.
Web Search plugin activated — enable it on the MiMo platform console: 👉 https://platform.xiaomimimo.com/#/console/plugin
Pi configured with MiMo — add your API key to
~/.pi/agent/auth.json:{ "xiaomi": { "type": "api_key", "key": "sk-your-api-key-here" } }
Install
Copy the extension to Pi's global extensions directory:
mkdir -p ~/.pi/agent/extensions/mimo-web-search
cp index.ts ~/.pi/agent/extensions/mimo-web-search/
Then restart Pi or run /reload.
You should see [mimo-web-search] in the extensions list at startup, and a notification confirming it loaded.
How It Works
The extension registers a single event handler:
before_provider_request → injects {"type": "web_search", "web_search": {}} into tools array
It targets only the xiaomi provider (direct API). Token plan providers are explicitly skipped because MiMo does not support web search on token plan endpoints.
Billing
Web search uses pay-as-you-go credits, separate from your API key usage or any token plan subscription. Each search request consumes credits based on the number of searches performed and pages crawled. Check your usage on the MiMo platform console.
Limitations
No Structured Citations in Pi
MiMo returns structured URL annotations (url_citation objects with title, URL, and summary) in the streaming response. However, Pi's openai-completions handler drops these annotations from the stream — it only processes content, tool_calls, and reasoning_content fields.
This means:
- ✅ The model receives search results and uses them to answer
- ✅ The model can mention sources by name in its text (e.g., "according to Reuters")
- ❌ Structured citations (clickable URLs, source cards) are not displayed in the TUI
The model will often cite sources naturally in its response text, but the links themselves won't be rendered. This is a Pi limitation, not a MiMo limitation — the annotations are sent by MiMo but discarded by Pi's streaming handler.
Token Plan Not Supported
Web search is not available on MiMo token plan endpoints (token-plan-sgp, token-plan-cn, token-plan-ams). If you try to use web search with a token plan key, MiMo returns:
web search tool found in the request body, but webSearchEnabled is false
This extension automatically skips token plan providers to avoid this error. If you switch between token plan and direct API, the extension will only activate web search when using the xiaomi (direct API) provider.
Model-Driven Search
The web_search tool is sent with force_search: false (the default), meaning the model decides when to search. It will search for current events, recent news, or real-time information, but won't search when you're asking it to write code, explain concepts, or do tasks that don't require up-to-date information. This is usually the desired behavior — it avoids wasting credits on queries that don't need web search.
Development
The extension is a single TypeScript file. To modify it:
- Edit
~/.pi/agent/extensions/mimo-web-search/index.ts - Run
/reloadin Pi - Test with a query that benefits from web search (e.g., "what's the latest news on X?")
Extension Structure
export default function (pi: any) {
// Notify on load
pi.on("session_start", ...);
// Inject web_search tool into MiMo requests
pi.on("before_provider_request", (event, ctx) => {
// Check if current model is a MiMo direct API provider
// Inject web_search tool into the tools array
// Return modified payload
});
}
Relevant Pi Extension API
before_provider_request— fires before each LLM request, can modify the payloadsession_start— fires when a session starts, used for the load notificationctx.model.provider— the current model's provider ID (e.g.,"xiaomi","xiaomi-token-plan-sgp")