No description
| src | ||
| .editorconfig | ||
| .env.example | ||
| .gitignore | ||
| .oxlintrc.json | ||
| .prettierignore | ||
| .prettierrc | ||
| bun.lock | ||
| CLAUDE.md | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
kagi-search
CLI tool for searching the web using the Kagi Search API. Optimized for LLM consumption with markdown output and intelligent caching.
Prerequisites
- Bun runtime
- Kagi API key (get one here)
Setup
- Install dependencies:
bun install
- Set your API key:
export KAGI_API_KEY=your_key_here
Or create a .env file:
cp .env.example .env
# Edit .env and add your API key
Usage
Development
bun run dev -- "your search query"
Build Binary
bun run build
This creates a standalone binary at dist/kagi-search.
Install Globally
bun run build
ln -s $(pwd)/dist/kagi-search /usr/local/bin/kagi-search
CLI Options
kagi-search <query> [options]
Options:
--limit <n> Limit number of results (default: 10)
--offset <n> Skip first n results (default: 0)
--json Output raw JSON
--include-related Include related searches in output
--help Show help message
Examples
Basic search
kagi-search "python async await tutorial"
Limit results
kagi-search "AI news" --limit 5
Pagination
kagi-search "recipes" --offset 10 --limit 5
JSON for scripting
kagi-search "github stars" --json | jq '.data[].url'
Include related searches
kagi-search "rust programming" --include-related
Features
- Markdown output: Clean, structured format optimized for LLM consumption
- Intelligent caching: Results cached for 1 hour to reduce API costs and latency
- Exit codes:
- 0: Success
- 1: General error
- 2: Missing API key
- 3: API request failed
- 4: Invalid arguments
Cache
Search results are cached in ~/.cache/kagi-search/ for 1 hour. If you search again with the same query and the offset+limit fits within the cached data, results are served from cache instead of hitting the API.
API Pricing
Kagi Search API is priced at $25 for 1000 queries. The caching mechanism helps reduce costs for repeated searches.
License
MIT