opencode-tool-kagi
v2.0.0
Published
OpenCode custom tools powered by the Kagi API — replaces built-in websearch with Kagi's premium search
Readme
opencode-tool-kagi
OpenCode plugin powered by the Kagi API — replaces the built-in websearch/webfetch with Kagi's premium search and extraction.
OpenCode v2 required. This release ships an OpenCode v2 plugin that registers Kagi as a websearch provider and stores the API key in OpenCode's credential store. The
.opencode/tools/copy install from the 1.x line is deprecated and will be removed in a future release.
| Tool | Replaces built-in | Description |
|------|-------------------|-------------|
| websearch | ✅ websearch | Premium web search via Kagi (registered as the default websearch provider) |
| webfetch | ✅ webfetch | Fetch and extract markdown from a URL |
| kagi_extract | — | Explicit extract markdown content from 1–10 URLs |
Setup
OpenCode v2 (recommended)
Install the plugin through OpenCode:
opencode plugin add opencode-tool-kagiOr add it to opencode.jsonc yourself:
{
"$schema": "https://opencode.ai/config.json",
"plugins": ["opencode-tool-kagi"],
}Then connect your Kagi account from the TUI — the key is stored in opencode's credential store, not in a plaintext file:
/connect
# Select Kagi, then paste your API key.Plugin options can disable individual pieces:
{
"plugins": [
{
"package": "opencode-tool-kagi",
"options": { "websearch": true, "webfetch": true, "extract": true },
},
],
}OpenCode v1 (legacy)
npx opencode-tool-kagiOr locally:
npm run setupThe interactive wizard guides you through:
- Install scope — per-project (
.opencode/tools/) or global (~/.config/opencode/tools/) - Tools selection — all tools with built-in overrides, or just
kagi_extract - API key — optional; set it now or later via
KAGI_API_KEYenv var
Requirements
- OpenCode v2 (plugin) or v1 (copied tools)
- Node.js >= 18 for the v1 wizard
- A Kagi API key
API key resolution
The key is looked up in this order:
- The Kagi credential stored by opencode (
/connect, orKAGI_API_KEYexposed as an integration connection) KAGI_API_KEYenvironment variable~/.config/opencode/kagi-api-key(global, written by the v1 installer).opencode/kagi-api-key(per-project)
On OpenCode v2 the plugin registers a kagi integration, so /connect manages the key through opencode's auth system. The file/env fallbacks remain for the v1 tools.
Usage
Once installed, use the tools directly in opencode:
> websearch "latest ai research papers 2026"
> webfetch https://example.com/article
> kagi_extract urls: ["https://example.com/article"]Tools
websearch
Replaces the built-in websearch with Kagi's premium search by registering Kagi as the default websearch provider.
webfetch
Replaces the built-in webfetch with Kagi Extract.
| Arg | Type | Required | Description |
|-----|------|----------|-------------|
| url | string | ✅ | A single URL to fetch |
| format | enum | — | Accepted for compatibility; Kagi always returns markdown |
| timeout | number | — | Time budget in seconds for the extraction |
kagi_extract
Explicit extract tool — clean markdown from URLs.
| Arg | Type | Required | Description |
|-----|------|----------|-------------|
| urls | string[] | ✅ | 1–10 URLs to extract |
| timeout | number | — | Time budget in seconds for the bulk extraction (clamped by Kagi) |
| max_chars | number | — | Max characters per URL (truncated locally) |
