@mjakl/pi-kagi-search
v1.0.2
Published
Kagi search tool for Pi coding agent
Readme
Pi Kagi Search
Kagi search tool for Pi agent. Uses your existing Kagi subscription via session token.
Why Pi Kagi Search
Uses Existing Subscription — If you have a Kagi subscription, you can use this extension without needing a separate API key. Just provide your session token.
High-Quality Results — Kagi is designed for relevance over ads. In practice, this often means cleaner, more useful results with less SEO noise, so Pi can start from stronger sources.
Better Research Flow — When search results are high-signal, the agent spends less time filtering low-value pages and more time helping you solve the real problem.
Install
Option 1: Install from npm (recommended)
Once the package is published to npm:
pi install npm:@mjakl/pi-kagi-searchIf it is not published yet, use Option 2 or 3 below.
Option 2: Install via git
pi install git:github.com/mjakl/pi-kagi-searchOption 3: Manual Installation
Clone this repository to your Pi extensions directory:
cd ~/.pi/agent/extensions
git clone https://github.com/mjakl/pi-kagi-search.git
cd pi-kagi-search
npm installConfiguration
Get Your Session Token
- Log in to Kagi
- Go to Settings → User Details
- Find your Session Link or visit kagi.com/settings?p=token
- Extract the
tokenvalue from the URL
Set the Token
Option 1: Environment Variable (Recommended)
export KAGI_SESSION_TOKEN="your-token-here"Add to your shell profile (~/.zshrc, ~/.bashrc) to persist.
Option 2: Interactive Login
pi
# Then use the command:
/kagi-loginOption 3: Config File
Create ~/.pi/kagi-search.json:
{
"sessionToken": "your-token-here"
}Option 4: Plain Text File
Create ~/.kagi_session_token with just the token:
echo "your-token-here" > ~/.kagi_session_tokenThis is checked as the last fallback if other methods are not configured.
Web Fetching
For fetching page contents, we recommend using a dedicated webfetch tool like Ben Vargas' Firecrawl extension. The agent can also fall back to curl to retrieve content when needed.
Commands
| Command | Description |
|---------|-------------|
| /kagi-login | Set your Kagi session token interactively |
Security Note
Your session token provides access to your Kagi account. Keep it private and treat it like a password. The token can be stored in:
- Environment variable (most secure for shell sessions)
~/.pi/kagi-search.jsonconfig file~/.kagi_session_tokenplain text file (last fallback)
Comparison to Kagi API
| Feature | Kagi API | This Extension | |---------|----------|----------------| | Requires API access | Yes (invite-only) | No | | Uses existing subscription | No | Yes | | Search | Yes | Yes | | Rate limits | API limits | Account limits |
This extension is useful if you have a Kagi subscription but don't have API access yet.
Related Projects
- kagi-ken - The Node.js library this extension is based on
- kagi-ken-mcp - MCP server for Claude
- pi-web-access - Similar extension with Perplexity/Gemini support
Author
Inspired by kagi-ken by Carlo Zottmann.
License
MIT
