Skip to main content

kagi assistant

Prompt Kagi Assistant, continue an existing thread, use a saved assistant profile, and manage both Assistant threads and custom assistants from the terminal. Assistant demo

Synopsis

Authentication

Required: KAGI_SESSION_TOKEN The Assistant feature uses Kagi’s authenticated web-product flow, not the paid public API token path.

Prompt Mode

Use prompt mode to start a new thread or continue an existing one:

Prompt Arguments

<QUERY>

The prompt to send to Kagi Assistant.

--thread-id <THREAD_ID>

Continue an existing Assistant thread.

--assistant <ASSISTANT>

Use a saved assistant by exact name, profile id, or invoke-profile slug.

--format <FORMAT>

Output format for prompt mode. Possible values:
  • json - pretty JSON
  • toon - token-efficient structured output for LLM context
  • pretty - terminal-friendly thread id, message id, and reply content
  • compact - minified JSON
  • markdown - only the assistant reply content

--contract <NAME>

Ask Assistant to return only JSON that satisfies a built-in contract, then validate the final reply before printing it. Contract mode supports --format json and --format compact. Supported built-ins:
  • decision - requires decision, rationale, and next_actions
  • checklist - requires items
  • plan - requires steps
If the first reply is invalid, the CLI sends one repair prompt in the same thread. If the repaired reply still fails validation, the command exits with a contract error.

--contract-file <PATH>

Load a small JSON contract file. The supported subset is a top-level object with required and optional properties.<key>.type fields:
Required entries default to string when properties does not specify a type. Supported types are string, number, integer, boolean, object, and array.

--no-color

Disable ANSI colors in --format pretty.

--stream

Stream Assistant output as it arrives instead of waiting for the final response. By default this writes incremental markdown deltas to stdout and flushes after each update:
Use JSON mode when a script needs structured stream events:

--stream-output <MODE>

Select the streamed output mode. This option requires --stream. Possible values:
  • text - default, prints only incremental markdown deltas
  • json - newline-delimited compact JSON events with md_delta, thread, message, and meta

--model <MODEL>

Override the model slug for a single prompt.

--lens <LENS_ID>

Override the Assistant lens id for a single prompt. This is the Assistant profile lens_id, not the search-command lens index used by kagi search --lens.

--web-access

--no-web-access

Force internet access on or off for a single prompt.

--personalized

--no-personalized

Force Kagi personalizations on or off for a single prompt.

REPL Mode

kagi assistant repl starts a terminal chat loop that keeps the latest Assistant thread id and sends each prompt back into the same conversation.
REPL commands:
  • /thread - print the active thread id
  • /exit or /quit - close the REPL
Useful options:
  • --thread-id <THREAD_ID> - continue an existing thread
  • --assistant <ASSISTANT> - use a saved assistant
  • --model <MODEL> - set the model for prompts in the session
  • --format <FORMAT> - markdown, pretty, json, or compact
  • --export <PATH> - write a JSON transcript on exit

Thread Subcommands

kagi assistant thread list

List Assistant threads for the current account.

kagi assistant thread get <THREAD_ID_OR_CHAT_URL>

Fetch one thread with its messages. This accepts either the thread ID or a Kagi Assistant chat URL.

kagi assistant thread delete <THREAD_ID_OR_CHAT_URL>

Delete one thread.

kagi assistant thread export <THREAD_ID_OR_CHAT_URL>

Export one thread as markdown to stdout.

kagi assistant thread export <THREAD_ID_OR_CHAT_URL> --format json

Return the thread as structured JSON instead of markdown. This emits the same envelope shape as thread get.

Custom Assistant Subcommands

kagi assistant custom list

List built-in and custom assistants visible to the current account.

kagi assistant custom get <ID_OR_NAME>

Fetch one custom assistant definition by id or exact name.

kagi assistant custom create <NAME>

Create a custom assistant. Supported options:
  • --bang-trigger <TRIGGER> - optional trigger without the leading !
  • --web-access / --no-web-access
  • --lens <LENS_ID>
  • --personalized / --no-personalized
  • --model <MODEL>
  • --instructions <TEXT>

kagi assistant custom update <ID_OR_NAME>

Update a custom assistant by id or exact name.

kagi assistant custom delete <ID_OR_NAME>

Delete a custom assistant by id or exact name.

Output Contract

Prompt mode returns:
Contract mode returns only the validated contract JSON, not the normal Assistant envelope:
thread list returns:
custom list returns an array of assistant summaries:

Examples

Start a thread, capture the id, continue it, then export it:
Use a saved assistant profile with terminal-readable output:
List custom assistants and inspect one:

Notes

  • Prompt mode now supports json, pretty, compact, and markdown.
  • thread export defaults to markdown because that is the natural terminal transcript format.
  • assistant custom list includes built-in assistants as well as user-created ones.
  • File-upload Assistant flows are intentionally out of scope in this CLI today.

See Also