| name | kagi-cli |
| description | Terminal CLI for Kagi subscribers with search, quick answers, assistant, translate, summarization, batch processing, and JSON-first output for automation. Use this skill when the user mentions kagi, wants to search via kagi, needs CLI-based AI assistance, or wants terminal access to Kagi features. |
| license | MIT |
| compatibility | Requires Kagi subscription for most features. Works on macOS, Linux, and Windows. Install via Homebrew, Scoop, npm, or direct script. |
| metadata | {"author":"Microck","version":"0.4.6","repository":"https://github.com/Microck/kagi-cli","npm":"https://www.npmjs.com/package/kagi-cli","docs":"https://kagi.micr.dev"} |
Overview
kagi-cli is a terminal CLI that provides command-line access to Kagi search, Quick Answer, AI Assistant, translation, summarization, public feeds through news and smallweb, and account-level search settings like lenses, custom assistants, custom bangs, and redirects. It outputs JSON by default for scripting and automation, with --format pretty for human-readable terminal output on the commands that support alternate renderers.
The CLI prioritizes the subscriber session-token path, so existing Kagi subscribers can use most features without paying for API access. Paid API features (summarize, fastgpt, enrich) are available by setting KAGI_API_TOKEN.
Installation
brew tap Microck/kagi
brew install kagi
scoop bucket add kagi https://github.com/Microck/scoop-kagi
scoop install kagi
npm install -g kagi-cli
curl -fsSL https://raw.githubusercontent.com/Microck/kagi-cli/main/scripts/install.sh | sh
irm https://raw.githubusercontent.com/Microck/kagi-cli/main/scripts/install.ps1 | iex
Authentication
Interactive Setup (Recommended)
kagi auth
Opens a guided TTY wizard that walks through:
- Choosing Session Link (subscriber, free) or API Token (paid)
- Pasting credentials
- Saving to
./.kagi.toml
- Immediate validation
Non-Interactive Setup
kagi auth set --session-token 'https://kagi.com/search?token=...'
export KAGI_SESSION_TOKEN='...'
export KAGI_API_TOKEN='...'
Auth Model
| Credential | What It Unlocks |
|---|
KAGI_SESSION_TOKEN | base search fallback, search --lens, search --news, filtered search, quick, ask-page, assistant, translate, summarize --subscriber |
KAGI_API_TOKEN | summarize, fastgpt, enrich web, enrich news |
| none | news, smallweb, auth status, --help |
Environment variables override ./.kagi.toml. When both tokens are present, base kagi search defaults to session token; set [auth] preferred_auth = "api" in config to prefer API.
Commands
kagi search
Search Kagi with JSON output by default.
kagi search "query"
kagi search --format pretty "query"
kagi search --lens 2 "query"
kagi search --news "iran"
kagi search --time month --region us --order recency "rust release notes"
kagi search --from-date 2026-03-01 --to-date 2026-03-31 "rust release notes"
kagi search --limit 5 "rust release notes"
kagi search --no-personalized "rust release notes"
kagi search --format markdown "query" > results.md
kagi quick
Get a direct answer with references instead of a list of results.
kagi quick --format pretty "what is rust"
kagi quick "capital of japan" | jq -r '.message.markdown'
kagi quick --format markdown "explain async/await" > notes.md
Output includes the answer, structured references, and follow-up questions.
kagi translate
Translate text through Kagi Translate with language detection and extras.
kagi translate "Bonjour tout le monde"
kagi translate "Hello world" --to es
kagi translate "Good morning" --to de | jq -r '.translation.translation'
kagi translate "text" --to ja --no-alternatives --no-word-insights
Includes alternatives, word insights, alignments, and suggestions by default.
kagi batch
Run multiple searches in parallel with rate limiting.
kagi batch "rust async" "python tutorial" "go concurrency"
kagi batch "query1" "query2" --format compact
kagi batch "product A review" "product B review" --format csv > comparison.csv
kagi assistant
Prompt Kagi Assistant and manage conversation threads.
kagi assistant "Explain quantum computing"
kagi assistant --thread-id "<thread-id>" "Give me an example"
kagi assistant --assistant research --model gpt-5-mini --web-access --no-personalized "Summarize the latest Rust release"
kagi assistant thread list
kagi assistant thread get "<thread-id>"
kagi assistant thread export "<thread-id>" --format markdown > thread.md
kagi assistant thread delete "<thread-id>"
kagi assistant custom
Manage saved assistant profiles.
kagi assistant custom list
kagi assistant custom get "Release Notes"
kagi assistant custom create "Release Notes" --model gpt-5-mini --web-access --lens 2 --instructions "Focus on release diffs and migrations."
kagi assistant custom update "Release Notes" --bang-trigger relnotes --no-personalized
kagi assistant custom delete "Release Notes"
kagi ask-page
Ask the Assistant about a specific web page.
kagi ask-page https://example.com/article "What are the main points?"
kagi summarize
Summarize URLs or text using Kagi's summarizer.
kagi summarize --subscriber --url https://example.com
kagi summarize --subscriber --url "$URL" --summary-type keypoints --length digest
kagi summarize --url https://example.com --engine cecil
kagi news
Fetch Kagi News (public, no auth required), optionally with local content filters.
kagi news --category tech --limit 5
kagi news --category world | jq '.stories[0].title'
kagi news --list-filter-presets
kagi news --filter-preset politics
kagi news --filter-preset politics --filter-mode blur
kagi smallweb
Fetch the Kagi Small Web feed (public, no auth required).
kagi smallweb --limit 10
kagi fastgpt
Quick factual answers through the paid API.
kagi fastgpt "what changed in rust 1.86?"
kagi enrich
Query Kagi's enrichment indexes (paid API).
kagi enrich web "local-first software"
kagi enrich news "browser privacy"
kagi lens
Manage Kagi search lenses.
kagi lens list
kagi lens get "Default"
kagi lens create "Rust Docs" --included-sites rust-lang.org,docs.rs --shortcut rustdocs
kagi lens update "Rust Docs" --description "Rust docs only" --region us
kagi lens enable "Rust Docs"
kagi lens disable "Rust Docs"
kagi lens delete "Rust Docs"
kagi bang custom
Manage custom bangs.
kagi bang custom list
kagi bang custom get docs
kagi bang custom create "Docs" --trigger docs --template "https://docs.rs/releases/search?query=%s"
kagi bang custom update docs --shortcut-menu
kagi bang custom delete docs
kagi redirect
Manage redirect rules.
kagi redirect list
kagi redirect get '^https://old.example.com/(.*)|https://new.example.com/$1'
kagi redirect create '^https://old.example.com/(.*)|https://new.example.com/$1'
kagi redirect update '^https://old.example.com/(.*)|https://new.example.com/$1' '^https://old.example.com/(.*)|https://docs.example.com/$1'
kagi redirect enable '^https://old.example.com/(.*)|https://docs.example.com/$1'
kagi redirect disable '^https://old.example.com/(.*)|https://new.example.com/$1'
kagi redirect delete '^https://old.example.com/(.*)|https://docs.example.com/$1'
Output Formats
search and batch support json, pretty, compact, markdown, and csv. quick and assistant support json, pretty, compact, and markdown. Commands like translate, news, smallweb, fastgpt, enrich, ask-page, and summarize emit JSON only.
| Format | Use Case |
|---|
json | Default, for scripting and jq pipelines |
pretty | Human-readable terminal output with colors |
compact | Condensed output for quick scanning |
markdown | Documentation-ready output |
csv | Spreadsheet-compatible |
kagi search "query" --format json | jq '.'
kagi search "query" --format pretty
kagi search "query" --format markdown > results.md
kagi search "query" --format csv > results.csv
Shell Completions
Generate completion scripts for Bash, Zsh, Fish, and PowerShell:
kagi --generate-completion bash > ~/.local/share/bash-completion/completions/kagi
kagi --generate-completion zsh > ~/.zsh/completion/_kagi
kagi --generate-completion fish > ~/.config/fish/completions/kagi.fish
kagi --generate-completion powershell >> $PROFILE
Common Workflows
Research Pipeline
kagi quick --format pretty "topic overview"
kagi search --time month --format pretty "topic research"
kagi batch "topic history" "topic applications" "topic future" --format compact
kagi assistant "Summarize what I found about topic"
Daily News Briefing
kagi news --category tech --limit 5
Content Analysis
kagi summarize --subscriber --url "$URL" --summary-type keypoints
kagi ask-page "$URL" "What is the author's main argument?"
Translation Workflow
kagi translate "text" --to es
kagi translate "text" --to de | jq '{
translation: .translation.translation,
alternatives: .alternatives.elements[0:3],
insights: .word_insights.insights[0:5]
}'
Assistant Thread Management
kagi assistant "Help me understand X" > thread.json
THREAD_ID=$(cat thread.json | jq -r '.thread.id')
kagi assistant --thread-id "$THREAD_ID" "Now explain Y"
kagi assistant thread export "$THREAD_ID" --format markdown > research.md
Batch Research
kagi batch "rust vs go" "python vs ruby" "react vs vue" --format pretty
kagi batch "topic1" "topic2" "topic3" --format csv > comparison.csv
Input Requirements
- Search queries: Text strings; optionally with
--lens, --time, --region, --order filters
- Quick queries: Natural language questions
- Translate text: Text string; optionally
--from and --to language codes
- URLs: Valid HTTP/HTTPS URLs for summarize and ask-page
- Thread IDs: Alphanumeric strings from assistant responses
- Categories: News categories: world, usa, tech, science, business, etc.
Constraints
- Session token required for: search --lens, search --news, quick, ask-page, assistant, translate, summarize --subscriber
- API token required for: summarize (public API), fastgpt, enrich
- Rate limits apply based on Kagi subscription tier
- API usage has per-query costs; session-based features included with subscription
- Translation requires session token
Error Handling
| Error | Resolution |
|---|
missing credentials | Run kagi auth or set KAGI_SESSION_TOKEN |
auth check failed | Verify token is valid and not expired |
403/401 | Check token permissions and subscription status |
invalid lens | Use valid lens index from your Kagi account |
rate limited | Wait and retry; reduce batch concurrency |
Resources