@pi-lab/xsearch
xAI-powered X search tool extension for pi coding agent
Package details
Install @pi-lab/xsearch from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@pi-lab/xsearch- Package
@pi-lab/xsearch- Version
1.0.3- Published
- Jul 7, 2026
- Downloads
- 234/mo · 20/wk
- Author
- cheny341
- License
- MIT
- Types
- extension
- Size
- 16.3 KB
- Dependencies
- 0 dependencies · 3 peers
Pi manifest JSON
{
"extensions": [
"./dist/index.mjs"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@pi-lab/xsearch 
A pi extension that adds an API-key based xsearch tool powered by xAI Grok x_search.
Prefer @pi-lab/grok-build for most X/Twitter tasks if the local Grok Build CLI is installed and authenticated. Grok Build can search X and read post/thread links with richer context, but its native X search usually returns about 10 posts per search call.
xsearchis still useful for broader API-key based searches that need more posts or many citation URLs.
Install
pi install npm:@pi-lab/xsearch
Usage
Set your xAI API key before starting pi:
export XAI_API_KEY=<your-api-key>
pi
You can also provide XAI_API_KEY through @pi-lab/env.
Once installed and configured, ask pi to search X/Twitter through the xAI API. For example:
Search X for what people are saying about the latest Grok release.
The tool returns Grok's answer plus X citation URLs. It is not a raw tweet API and does not guarantee original post objects. For richer post/thread reading, replies, quotes, media details, views, or bookmarks, prefer grok_build.
Settings
Configure behavior in pi settings. User settings live at ~/.pi/agent/settings.json; project settings live at <cwd>/.pi/settings.json. Project settings override user settings.
{
"xsearch": {
"model": "grok-4-1-fast-non-reasoning",
"enableImageUnderstanding": false,
"enableVideoUnderstanding": false
}
}
Defaults:
model:grok-4-1-fast-non-reasoningenableImageUnderstanding:falseenableVideoUnderstanding:false
See the official xAI docs when choosing a model and estimating cost:
- xAI models — available models, pricing, and tool costs.
- xAI X Search — supported
x_searchbehavior and parameters.
For most routine searches, use a fast/non-reasoning model such as grok-4-1-fast-non-reasoning. Use a stronger reasoning model only when you need deeper synthesis, since model choice affects latency and token cost. Media understanding can add extra cost, so it defaults to disabled.