kagi is a terminal CLI for Kagi that gives you command-line access to search, lenses, assistant, summarization, feeds, and paid API commands. it is built for people who want one command surface for interactive use, shell workflows, and structured JSON output.
the main setup path is your existing Kagi session-link URL. paste it into kagi auth set --session-token and the CLI extracts the token for you. if you also use Kagi's paid API, add KAGI_API_TOKEN and the public API commands are available too.
documentation | npm | github
if you already use Kagi and want to access it from scripts, shell workflows, or small tools, this CLI gives you a practical path without making the paid API flow the starting point.
- use your existing session-link URL for subscriber features
- get structured JSON for scripts, agents, and other tooling
- use one CLI for search, assistant, summarization, and feeds
- add
KAGI_API_TOKENonly when you want the paid public API commands
curl -fsSL https://raw.githubusercontent.com/Microck/kagi-cli/main/scripts/install.sh | sh
kagi --helpirm https://raw.githubusercontent.com/Microck/kagi-cli/main/scripts/install.ps1 | iex
kagi --helpnpm install -g kagi-cli
pnpm add -g kagi-cli
bun add -g kagi-cli
brew tap Microck/kagi
brew install kagi
scoop bucket add kagi https://github.com/Microck/scoop-kagi
scoop install kagiadd your subscriber session token:
how to get it:
- click the top-right menu icon
- go into
Settings - click
Accountin the left sidebar - in
Session Link, clickCopy
kagi auth set --session-token 'https://kagi.com/search?token=...'
kagi auth checkadd an api token when you want the paid public api commands:
how to get it:
- click the top-right menu icon
- go into
Settings - click
Advancedin the left sidebar - go into
Open API Portal - under
API Token, clickGenerate New Token
export KAGI_API_TOKEN='...'| credential | what it unlocks |
|---|---|
KAGI_SESSION_TOKEN |
base search, search --lens, assistant, summarize --subscriber |
KAGI_API_TOKEN |
public summarize, fastgpt, enrich web, enrich news |
| none | news, smallweb, auth status, --help |
example config:
[auth]
# Full Kagi session-link URL or just the raw token value.
session_token = "https://kagi.com/search?token=kagi_session_demo_1234567890abcdef"
# Paid API token for summarize, fastgpt, and enrich commands.
api_token = "kagi_api_demo_abcdef1234567890"
# Base `kagi search` auth preference: "session" or "api".
preferred_auth = "api"notes:
kagi auth set --session-tokenaccepts either the raw token or the full session-link URL- environment variables override
.kagi.toml - base
kagi searchdefaults to the session-token path when both credentials are present - set
[auth] preferred_auth = "api"if you want base search to prefer the API path instead search --lensalways requiresKAGI_SESSION_TOKENauth checkvalidates the selected primary credential without using search fallback logic
for the full command-to-token matrix, use the auth-matrix docs page.
| command | purpose |
|---|---|
kagi search |
search Kagi with JSON by default or --format pretty for terminal output |
kagi batch |
run multiple searches in parallel with JSON, compact, pretty, markdown, or csv output |
kagi auth |
inspect, validate, and save credentials |
kagi summarize |
use the paid public summarizer API or the subscriber summarizer with --subscriber |
kagi news |
read Kagi News from public JSON endpoints |
kagi assistant |
prompt Kagi Assistant with a subscriber session token |
kagi fastgpt |
query FastGPT through the paid API |
kagi enrich |
query Kagi's web and news enrichment indexes |
kagi smallweb |
fetch the Kagi Small Web feed |
for automation, stdout stays JSON by default. --format pretty only changes rendering for humans.
generate a completion script and install it with your shell of choice:
# bash
kagi --generate-completion bash > ~/.local/share/bash-completion/completions/kagi
# zsh
kagi --generate-completion zsh > ~/.zsh/completion/_kagi
# fish
kagi --generate-completion fish > ~/.config/fish/completions/kagi.fishsee the installation guide for platform-specific setup details.
use search as part of a shell pipeline:
kagi search "what is mullvad"switch the same command to terminal-readable output:
kagi search --format pretty "how do i exit vim"scope search to one of your lenses:
kagi search --lens 2 "developer documentation"run a few searches in parallel:
kagi batch "rust programming" "python tutorial" "go language"change batch output format for shell pipelines:
kagi batch "rust" "python" "go" --format compactcontinue research with assistant:
kagi assistant "plan a focused research session in the terminal"use the subscriber summarizer:
kagi summarize --subscriber --url https://kagi.com --summary-type keypoints --length digestuse the paid api summarizer:
kagi summarize --url https://example.com --engine cecilget a faster factual answer through the paid api:
kagi fastgpt "what changed in rust 1.86?"query enrichment indexes:
kagi enrich web "local-first software"
kagi enrich news "browser privacy"if you want a quick feel for the cli before installing it, this is the kind of output you get from the subscriber summarizer, assistant, and public news feed:
if you are working on the cli itself, build from a local checkout:
git clone https://github.com/Microck/kagi-cli.git
cd kagi-cli
cargo build --release
./target/release/kagi --helpfor the fuller install matrix and platform-specific setup, use the installation guide.





