Skip to main content

Command Line Interface (CLI)

Use the Knowhere CLI to parse documents, inspect outlines, sync local chunk storage, and run retrieval from your terminal.

The CLI package ships two binaries over the same Knowhere SDK-backed core:

BinaryUse it forOutput
knowhereInteractive terminal UI (TUI)Rich terminal screens for local exploration
knowhere-cliHeadless scriptingPlain text by default, or JSON with --json

Both binaries use the same authentication and command vocabulary. Start in the TUI when you want to explore documents manually, and use the headless binary when you need automation in scripts or CI.

Prerequisites

  • Node.js 22+
  • A Knowhere dashboard login or a KNOWHERE_API_KEY
  • A terminal that supports interactive output when using the knowhere TUI

Install the CLI

Run the headless binary without installing it globally:

npx -y @ontos-ai/knowhere-cli --help
npx -y @ontos-ai/knowhere-cli status job_abc123 --json

To run the interactive knowhere binary through npx, select the binary explicitly:

npx -y -p @ontos-ai/knowhere-cli knowhere

Authenticate

The CLI resolves credentials in this order:

  1. --api-key
  2. KNOWHERE_API_KEY
  3. Stored dashboard login from knowhere login

Use browser login for local interactive work:

knowhere login

The login flow opens the Knowhere dashboard, asks for read-only or full-access permission, and stores credentials at ~/.knowhere/credentials.json. The CLI refreshes the access token automatically. Use knowhere logout to revoke and clear the local session.

Set KNOWHERE_BASE_URL or pass --base-url when working against a non-default environment:

KNOWHERE_BASE_URL="https://staging.knowhereto.ai" knowhere login

Browser login requires the interactive knowhere binary. For headless environments, use an API key.

Commands

Command names use the product-facing terminal vocabulary. The older SDK-style aliases remain accepted for compatibility.

CommandAliasDescription
ingest FILE_OR_URL_OR_IDparseUpload and process a document, then cache the result locally.
inspect FILE_OR_URL_OR_IDExplore the parsed outline tree for a file, URL, local document ID, or Knowhere doc_* ID.
sync DOC_ID_OR_JOB_IDRefresh local chunk storage for a parsed result.
status JOB_IDCheck a parsing job's status.
download JOB_IDloadDownload and unpack a finished job result.
retrieve TEXTqueryRun semantic search across published documents.
login / logout / whoamiManage the local session. login and logout are available on the interactive knowhere binary.

ingest parses files or URLs through the Knowhere API in the shared default namespace, tags the published document metadata as CLI-created, and caches the result locally. Published Knowhere documents from default are localized into the same local cache before home, inspect, sync, and retrieve use them.

Interactive usage

Launch the terminal UI:

knowhere

Common TUI commands:

knowhere login
knowhere ingest ./report.pdf
knowhere inspect ldoc_a1b2c3
knowhere sync ldoc_a1b2c3
knowhere retrieve "What are the main risks?" --top-k 5
knowhere status job_abc123
knowhere download job_abc123 -o ./output

Use --no-animation to disable reveal animations. Animations are skipped automatically when output is not an interactive terminal.

Headless usage

Use knowhere-cli when a script needs stable stdout and exit codes:

knowhere-cli status job_abc123
knowhere-cli status job_abc123 --json
knowhere-cli retrieve "main risks" --top-k 3 --json

Errors are written to stderr and exit with a non-zero code, so the headless binary composes cleanly in shell scripts and pipelines.

Inspect and sync documents

inspect accepts:

  • a local file path
  • a remote URL
  • a local document ID such as ldoc_a1b2c3
  • a published Knowhere document ID such as doc_abc123

By default, inspect refreshes local chunk/result storage before rendering. Use --no-sync when you want to inspect the current local copy without refreshing it:

knowhere inspect doc_abc123 --no-sync
knowhere-cli inspect doc_abc123 --depth 3 --json

Use sync when you want to refresh storage explicitly:

knowhere sync doc_abc123
knowhere-cli sync job_abc123 --json

When the cached result has a server document ID, the inspect screen includes a Notebook chunk-tree link.

Options

OptionApplies toDescription
--api-key, -kallAPI key. Defaults to KNOWHERE_API_KEY.
--base-url, -ballKnowhere site base URL. Defaults to KNOWHERE_BASE_URL, then https://knowhereto.ai; API and login routes are derived from it.
--output, -odownloadOutput directory. Defaults to ./output.
--query, -qretrieveQuery text. You can also pass the text positionally.
--top-kretrieveNumber of retrieval results. Defaults to 5.
--namespaceretrieveRetrieval namespace.
--depthinspectMaximum outline depth to render.
--sync / --no-syncinspectEnable or disable local chunk/result refresh before inspect. Default is on.
--no-animationknowhereDisable reveal animations.
--jsoninspect, retrieve, knowhere-cli commandsEmit machine-readable JSON.

See also