Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

---

`kagi` is a terminal CLI for Kagi that gives you command-line access to search, lenses, ask-page, assistant, translate, 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.
`kagi` is a terminal CLI for Kagi that gives you command-line access to search, quick answers, lenses, ask-page, assistant, translate, 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.

Expand All @@ -29,7 +29,7 @@ if you already use Kagi and want to access it from scripts, shell workflows, or

- use your existing session-link URL for subscriber features
- get structured JSON for scripts, agents, and other tooling
- use one CLI for search, assistant, translate, summarization, and feeds
- use one CLI for search, quick answers, assistant, translate, summarization, and feeds
- add `KAGI_API_TOKEN` only when you want the paid public API commands

## quickstart
Expand Down Expand Up @@ -101,7 +101,7 @@ export KAGI_API_TOKEN='...'

| credential | what it unlocks |
| --- | --- |
| `KAGI_SESSION_TOKEN` | base search fallback, `search --lens`, filtered search, `ask-page`, `assistant`, `translate`, `summarize --subscriber` |
| `KAGI_SESSION_TOKEN` | base search fallback, `search --lens`, filtered search, `quick`, `ask-page`, `assistant`, `translate`, `summarize --subscriber` |
| `KAGI_API_TOKEN` | public `summarize`, `fastgpt`, `enrich web`, `enrich news` |
| none | `news`, `smallweb`, `auth status`, `--help` |

Expand Down Expand Up @@ -138,6 +138,7 @@ for the full command-to-token matrix, use the [`auth-matrix`](https://kagi.micr.
| `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 quick` | get a Quick Answer with references from the subscriber web product |
| `kagi assistant` | prompt Kagi Assistant, continue threads, and manage thread list/export/delete with a subscriber session token |
| `kagi ask-page` | ask Kagi Assistant about a specific web page |
| `kagi translate` | translate text through Kagi Translate with a subscriber session token |
Expand Down Expand Up @@ -221,6 +222,12 @@ kagi assistant thread list
kagi assistant thread export <THREAD_ID>
```

get a quick answer with references:

```bash
kagi quick --format pretty "what is rust"
```

translate text and keep all text-mode extras:

```bash
Expand Down Expand Up @@ -268,7 +275,9 @@ kagi enrich news "browser privacy"

## what it looks like

if you want a quick feel for the cli before installing it, this is the kind of output you get from translate, ask-page, the subscriber summarizer, assistant, and the public news feed:
if you want a quick feel for the cli before installing it, this is the kind of output you get from quick answer, translate, ask-page, the subscriber summarizer, assistant, and the public news feed:

![quick demo](images/demos/quick.gif)

![translate demo](images/demos/translate.gif)

Expand Down
3 changes: 3 additions & 0 deletions docs/api-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- **Small Web RSS feed** - implemented and live-verified
- **Subscriber web Summarizer** - implemented on the session-token web-product path via `kagi summarize --subscriber ...`
- **Kagi News public product endpoints** - implemented via `kagi news ...`
- **Subscriber web Quick Answer flow** - implemented on Kagi's authenticated Quick Answer stream via `kagi quick ...`
- **Subscriber web Assistant prompt flow** - implemented on Kagi Assistant's authenticated tagged stream via `kagi assistant ...`
- **Subscriber web Assistant thread list/open/delete/export flows** - implemented on the authenticated Assistant thread endpoints via `kagi assistant thread ...`
- **Kagi Translate text mode** - implemented via `kagi translate ...` with runtime bootstrap from `KAGI_SESSION_TOKEN`
Expand All @@ -26,6 +27,7 @@ According to Kagi's public API docs, the documented API families are:

This CLI also implements non-public or product-only seams:
- subscriber web Summarizer via Kagi session-token auth
- subscriber web Quick Answer via Kagi session-token auth
- subscriber web Assistant prompt flow via Kagi session-token auth
- subscriber web Assistant thread management via Kagi session-token auth
- Kagi News product endpoints
Expand All @@ -41,4 +43,5 @@ This CLI also implements non-public or product-only seams:
- Live verification on March 18, 2026 showed that direct HTTP bootstrap can mint `translate_session` from the same `KAGI_SESSION_TOKEN` by reading the `Set-Cookie` header from `https://translate.kagi.com/`.
- After bootstrap, the CLI uses normal Rust HTTP requests for `/api/detect`, `/api/translate`, `/api/alternative-translations`, `/api/text-alignments`, `/api/translation-suggestions`, and `/api/word-insights`.
- Assistant requires `KAGI_SESSION_TOKEN` and currently targets `/assistant/prompt`, `/assistant/thread_list`, `/assistant/thread_open`, `/assistant/thread_delete`, and `/assistant/<thread_id>/download`.
- Quick Answer requires `KAGI_SESSION_TOKEN` and currently targets `POST /mother/context?q=...` with `Accept: application/vnd.kagi.stream`.
- News uses `https://news.kagi.com/api/...` JSON endpoints and does not require auth.
201 changes: 201 additions & 0 deletions docs/commands/quick.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
---
title: "quick"
description: "Complete reference for *kagi* quick command - get Kagi Quick Answer responses from the terminal."
---

# `kagi quick`

Generate a Kagi Quick Answer from the authenticated web product and return the full answer envelope, references, and follow-up questions.

![Quick Answer demo](/images/demos/quick.gif)

## Synopsis

```bash
kagi quick [OPTIONS] <QUERY>
```

## Description

`kagi quick` targets Kagi's Quick Answer web-product flow, not FastGPT and not the public Search API. It is useful when you want a fast answer plus references without opening a browser tab.

This command is ideal for:
- factual questions with references
- shell workflows that want a single answer envelope
- quick terminal lookups with `pretty` or `markdown` output
- automations that want the Quick Answer thread id for later inspection

## Authentication

**Required:** `KAGI_SESSION_TOKEN`

Quick Answer uses subscriber session-token auth. The CLI accepts either:
- the raw session token
- the full Session Link URL such as `https://kagi.com/search?token=...`

## Arguments

### `<QUERY>` (Required)

The text to send to Quick Answer.

The CLI sends the query verbatim. It does not auto-append a trailing question mark, so both of these are valid:

```bash
kagi quick "what is rust"
kagi quick "what is rust?"
```

## Options

### `--format <FORMAT>`

Output format for the response.

**Supported values:** `json`, `compact`, `pretty`, `markdown`

**Default:** `json`

```bash
kagi quick --format pretty "what is rust"
kagi quick --format markdown "what is rust"
```

### `--no-color`

Disable ANSI colors in `--format pretty`.

```bash
kagi quick --format pretty --no-color "what is rust"
```

### `--lens <INDEX>`

Scope the query to one of your Kagi lenses by numeric index.

```bash
kagi quick --lens 0 "best rust tutorials"
```

Lens indices are user-specific. Use the same `l=` numeric value you would use with `kagi search --lens`.

## Output Format

Default JSON output:

```json
{
"meta": {
"version": "202603171911.stage.707e740",
"trace": "trace-123"
},
"query": "what is rust",
"lens": null,
"message": {
"id": "msg-1",
"thread_id": "thread-1",
"created_at": "2026-03-19T00:00:00Z",
"state": "done",
"prompt": "what is rust",
"html": "<p>Rust is a systems programming language.</p>",
"markdown": "Rust is a systems programming language."
},
"references": {
"markdown": "[^1]: [Rust](https://www.rust-lang.org/) (26%)",
"items": [
{
"index": 1,
"title": "Rust",
"domain": "www.rust-lang.org",
"url": "https://www.rust-lang.org/",
"contribution_pct": 26
}
]
},
"followup_questions": [
"Why is Rust memory-safe?"
]
}
```

### Fields

| Field | Type | Description |
|-------|------|-------------|
| `meta` | object | Stream metadata such as version and trace id |
| `query` | string | The original query text sent to Quick Answer |
| `lens` | string or null | The requested lens index, if one was supplied |
| `message` | object | Final Quick Answer message payload |
| `references` | object | Reference markdown plus parsed reference items |
| `followup_questions` | array | Follow-up suggestions returned by Kagi |

## Examples

### Basic Queries

```bash
kagi quick "what is rust"
kagi quick "best way to clean cast iron"
```

### Pretty Terminal Output

```bash
kagi quick --format pretty "what is rust"
```

### Markdown for Notes

```bash
kagi quick --format markdown "what is rust?" > quick-answer.md
```

### Lens-Scoped Quick Answers

```bash
kagi quick --lens 0 "best rust tutorials"
```

### JSON Processing

```bash
# Extract the answer body
kagi quick "what is rust" | jq -r '.message.markdown'

# Extract reference URLs
kagi quick "what is rust" | jq -r '.references.items[].url'

# Save the Quick Answer thread id
kagi quick "what is rust" | jq -r '.message.thread_id'
```

## Output Modes

### `json`

Pretty-printed JSON envelope for scripts and inspection.

### `compact`

Minified JSON envelope for pipelines or storage-sensitive paths.

### `pretty`

Terminal-friendly answer text followed by a references section and any follow-up questions.

### `markdown`

The answer markdown, then the references markdown, then a follow-up section if present.

## Limitations

- Requires an active Kagi subscription and session token
- This command is single-turn only
- The returned `message.thread_id` is informational today; there is no `--thread-id` follow-up mode yet
- Output quality and references depend on the live Quick Answer product

## See Also

- [assistant](/commands/assistant) - Conversational multi-turn AI via Kagi Assistant
- [search](/commands/search) - Full search results instead of a single synthesized answer
- [Authentication](/guides/authentication) - Session-token setup
Binary file added docs/demo-assets/quick.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions docs/demos.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The demo scripts build the local debug binary, expose it as `kagi` through `/tmp
## Assets

- `docs/demo-assets/search.gif`
- `docs/demo-assets/quick.gif`
- `docs/demo-assets/summarize.gif`
- `docs/demo-assets/news.gif`
- `docs/demo-assets/ask-page.gif`
Expand All @@ -20,30 +21,32 @@ Subscriber demos require `KAGI_SESSION_TOKEN` in the environment. API-token demo
The current demo commands are:

- `kagi search --format pretty --region us --time year --order recency "rust release notes"`
- `kagi quick --format pretty "what is rust"`
- `kagi summarize --subscriber --url https://mullvad.net/en/browser | jq -M ...`
- `kagi news --category tech --limit 1 | jq -M ...`
- `kagi ask-page https://rust-lang.org/ "What is this page about in one sentence?" | jq -M ...`
- `kagi assistant "plan a private obsidian workflow for cafe work. give me 3 setup tips and a short checklist." | jq -M ...`
- `kagi translate "Bonjour tout le monde" --to ja | jq -M ...`
- `RESPONSE=$(kagi assistant --model gpt-5-mini "..."); THREAD_ID=...; kagi assistant --thread-id "$THREAD_ID" "..."; kagi assistant thread export "$THREAD_ID"`
- `kagi translate "Bonjour tout le monde" --to ja | jq -M ...`

```bash
chmod +x scripts/demo-search.sh scripts/demo-summarize.sh scripts/demo-news.sh scripts/demo-ask-page.sh scripts/demo-assistant.sh scripts/demo-translate.sh
chmod +x scripts/demo-search.sh scripts/demo-quick.sh scripts/demo-summarize.sh scripts/demo-news.sh scripts/demo-ask-page.sh scripts/demo-assistant.sh scripts/demo-translate.sh

mkdir -p docs/demo-assets /tmp/kagi-demos

agg --version
# expected: "asciinema gif generator"

KAGI_SESSION_TOKEN='...' asciinema rec -c ./scripts/demo-search.sh -q -i 0.2 --cols 92 --rows 22 /tmp/kagi-demos/search.cast
KAGI_SESSION_TOKEN='...' asciinema rec -c ./scripts/demo-quick.sh -q -i 0.2 --cols 92 --rows 22 /tmp/kagi-demos/quick.cast
KAGI_SESSION_TOKEN='...' asciinema rec -c ./scripts/demo-summarize.sh -q -i 0.2 --cols 92 --rows 22 /tmp/kagi-demos/summarize.cast
asciinema rec -c ./scripts/demo-news.sh -q -i 0.2 --cols 92 --rows 22 /tmp/kagi-demos/news.cast
KAGI_SESSION_TOKEN='...' asciinema rec -c ./scripts/demo-ask-page.sh -q -i 0.2 --cols 92 --rows 22 /tmp/kagi-demos/ask-page.cast
KAGI_SESSION_TOKEN='...' asciinema rec -c ./scripts/demo-assistant.sh -q -i 0.2 --cols 92 --rows 22 /tmp/kagi-demos/assistant.cast
KAGI_SESSION_TOKEN='...' asciinema rec -c ./scripts/demo-translate.sh -q -i 0.2 --cols 92 --rows 22 /tmp/kagi-demos/translate.cast

agg --theme asciinema --font-size 14 --idle-time-limit 2 --last-frame-duration 4 /tmp/kagi-demos/search.cast docs/demo-assets/search.gif
agg --theme asciinema --font-size 14 --idle-time-limit 2 --last-frame-duration 4 /tmp/kagi-demos/quick.cast docs/demo-assets/quick.gif
agg --theme asciinema --font-size 14 --idle-time-limit 2 --last-frame-duration 4 /tmp/kagi-demos/summarize.cast docs/demo-assets/summarize.gif
agg --theme asciinema --font-size 14 --idle-time-limit 2 --last-frame-duration 4 /tmp/kagi-demos/news.cast docs/demo-assets/news.gif
agg --theme asciinema --font-size 14 --idle-time-limit 2 --last-frame-duration 4 /tmp/kagi-demos/ask-page.cast docs/demo-assets/ask-page.gif
Expand Down
3 changes: 2 additions & 1 deletion docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@
{
"group": "AI & Enrichment",
"pages": [
"commands/ask-page",
"commands/assistant",
"commands/quick",
"commands/ask-page",
"commands/translate",
"commands/fastgpt",
"commands/enrich"
Expand Down
8 changes: 8 additions & 0 deletions docs/guides/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ kagi search --region us --time month --order recency "rust release notes"
![Search command demo](/images/demos/search.gif)

```bash
# Test Quick Answer
kagi quick --format pretty "what is rust"

# Test Assistant
kagi assistant "What are the key features of Rust?"

Expand All @@ -190,6 +193,10 @@ kagi assistant thread list
kagi summarize --subscriber --url https://www.rust-lang.org --summary-type keypoints --length digest
```

**Quick Answer Demo:**

![Quick command demo](/images/demos/quick.gif)

**Assistant Demo:**

![Assistant command demo](/images/demos/assistant.gif)
Expand Down Expand Up @@ -440,6 +447,7 @@ kagi search --lens 2 --format pretty "query" # Combined
```bash
kagi summarize --url https://example.com # Public API
kagi summarize --subscriber --url https://example.com # Subscriber
kagi quick "what is rust" # Quick Answer
kagi fastgpt "question" # Quick answer
kagi assistant "prompt" # AI assistant
kagi enrich web "query" # Web enrichment
Expand Down
Loading