Skip to main content
The NDI CLI (ndi) gives you terminal access to the same /v1 methods as the SDKs: parse, extract, split, classify, ground, plus workspaces, ingestion, and search. Use it for batch processing, scripting, CI/CD, and quick operations without writing application code.

Fast path for coding agents

Use the CLI when the document is already on disk or when an agent needs a terminal-first workflow. It avoids writing upload code and prints Markdown that agents can read directly.
A directory is scanned recursively for supported files, one job each:
For agent tool calling instead of terminal commands, use the MCP server.

Installation

Requires Python 3.11+. The executable is ndi. ndi version prints the CLI and the ndi-sdk it is talking through. To upgrade, see Update the SDKs, CLI, and MCP.

Authentication

This opens the NDI console in the browser and writes the minted key to ~/.ndi/config.toml. $NDI_API_KEY still wins over the file. $NDI_CONFIG_PATH overrides the config location. To paste a key instead of opening a browser:
Workspace-scoped verbs also need a workspace:
ndi workspace create prints the new workspace as JSON. The id is the workspace_id field. In a script, pass --json so the output is always JSON: ndi workspace create fy25-audit --json | jq -r .workspace_id. The default host is https://ndi-api.nace.ai. Override with $NDI_BASE_URL.

Quick examples

Results go to stdout: the full JSON response by default, and parsed markdown for ndi parse. Status lines (job <id> queued, saved …) go to stderr. -o auto|md|json|payload|id picks the shape. --json is an alias for -o json. --save PATH / --out-dir DIR write files. --async submits and prints the job id. See Output for when the default prints a shorter text rendering instead. When a Parse result has external complete content, -o auto and -o md print the inline preview. Use -o json or -o payload to read its disclosure and authenticated full-content URL. A final-size preview carries content_truncated; reduced-layout Office parsing carries parse_fidelity. Documents use document.content_url; workbooks use the affected document.spreadsheet.sheets[].content_url. The CLI does not download these URLs automatically. API failures exit 1. Usage and config errors exit 2. An unsupported single file is reported on stderr as error: 422 [unsupported_file_type] ...; the command does not print an upload handle or job ID, ndi files upload leaves no workspace file, and --ingest does not queue ingestion. A directory upload skips those files with a warning instead of failing the run.

Supported file types

Directory scans for document operations pick up these extensions (other files are skipped with a note on stderr). ndi files upload DIR also accepts the workspace-only types in Format support (HTML, plaintext, markdown, email, extra media). Per-operation gates are stricter and are enforced by the API for each file. Do not copy this table into automation as a permanent allowlist. Commands accept a file, a directory, an https:// URL, a staged ndi://upload/<uuid>, a prior parse jobid://<uuid> (not classify), a workspace file ws://<file_id>, or - (a handle line, or raw bytes with --file-name).

Parse

Converts a document into markdown, text, and layout blocks.

Flags

Examples

See Parse for what the result contains.

Extract

Pulls structured data against a JSON Schema you provide. The top-level schema must be an object. Pass exactly one of -s/--schema (file path or inline JSON) or --schema-id (a saved schema).
--validate checks the schema without creating a job. --instructions adds guidance. --no-citations drops cell/page citations. -p limits pages.
Extraction can reuse a prior parse: ndi parse a.pdf -o id | ndi extract - -s schema.json sends the job id on stdin instead of uploading the file again.
See Extract and Extraction schemas.

Split

Finds logical sections against classes you name. Each --class is id:label[:description]; --classes FILE.json takes an array of the same shape.
--unknown is include (default), force, or error.

Classify

Labels a document or its pages against your classes. Same --class / --classes shape as split.
--granularity is document (default) or page. --unknown is allow (default) or force_best. Classify cannot reuse a parse job — pass a file, URL, upload, or workspace file.

Ground

Locates quoted text back in the source.
Each --target is id=TEXT. --targets takes a JSON array of the same objects the API accepts.

Workspaces and files

A workspace is a persistent corpus. Upload, ingest, then search.
A directory walks nested files, keeps relative paths under --path (default: the directory name), and uploads in parallel (-j, default 8). Unsupported files and .DS_Store are skipped; a warning on stderr lists them when the run finishes. --ingest then queues ingestion in batches of 1000 file ids. A single file still requires --path. --on-conflict is reject (default) or new_version. Delete a workspace with --confirm-name equal to the workspace name. To keep a workspace’s files in customer storage, pick an existing ready connection and bind it at creation. Customer storage is not generally available; disabled deployments return not_implemented for every connection operation (including storage-connections list) and for creating a workspace with a connection, retries included; enabled deployments with incomplete configuration return storage_unavailable.
Connections and their credentials are set up in the console or with the Python or TypeScript SDK; the CLI never takes cloud secrets. Without --storage-connection, the workspace uses the organization default. See Workspaces and Ingest.

Search and journal-entry testing

Files must be ingested first. These verbs return jobs. To pick the right verb for a question, see Choose the right tool.
automatic-search, filtered-search, and je-testing wait for the job unless you pass --async. automatic-search prints the chosen route and the output job id; receipts and a catalog table’s cursor belong to that job. --mode fact or --mode agent runs that route with no router model and no routing charge. A catalog table’s next: cursor pages with ndi filtered-search --cursor.
ndi fact-search and ndi deep-search are removed in CLI 0.27.0: run automatic-search --mode fact or --mode agent instead. A new ndi filtered-search QUERY is deprecated and prints a note on stderr; use automatic-search. ndi filtered-search --cursor is not deprecated.
ndi ledger-understanding start waits the same way; get is a read and prints the stored report. JET uses --reasoning-effort to change its thinking budget without switching engines; omit it for the service default. --path on automatic-search, filtered-search and je-testing adds that file to the run’s scope; it is repeatable, has no limit, and adds to --prefix: the run covers the folder’s files plus the named ones. There is no --session-id: a shell has nowhere to keep a thread. Save background every query should know once, as the workspace’s global context:
je-testing and the searches run with it unless you pass --context, which replaces it for that run, or --no-context, which runs with no context at all. A catalog table, from automatic-search’s agent or a deprecated filtered-search QUERY, lists documents from the metadata catalog rather than by reading files. It prints a next: cursor when more rows remain; page it with ndi filtered-search --cursor <cursor>. A page is a new job that re-executes the original query against the current catalog, so --prefix and --context are refused with a cursor — they belong to the initial query — and the page’s own flags supersede the first run’s. There is no --result-unit (the server deprecates the grouping override) and no --allow-clarification (a clarification is answered by a new initial query, and a shell has nowhere to keep the thread). Read not exhaustive before treating a catalog table’s count as a census: the matches are valid, but the total is a floor. An unreadable or partly readable line names the field behind a thin result. Neither exits non-zero — both are successful partial answers. A degraded journal-entry testing run exits non-zero even though the job succeeded — the procedure broke before finalizing an answer. --force on ledger-understanding start re-measures even when a report for this package already exists. Without it, an unchanged package republishes the stored report. A workspace that has never produced a report exits on ledger_understanding_not_found. See Search, Automatic search, Journal-entry testing, and Ledger understanding.

Ask one file

ndi ask-file PATH QUERY asks one ingested file a question and prints a cited answer: a document, workbook, image, or recording. --component scopes it to one section or tab (a workbook’s tab names are its sheet names).
See Ask questions of files.

Locate, read, run SQL

ndi locate NEED names the pages and table tabs that hold a piece of information; ndi read-file reads them and ndi run-sql computes over the tables. Each prints exactly what NDI’s own search agent sees for the same call (--json for the full response). A locate without --locate-id starts a new locate id and prints it first (locate id: loc_…). Pass --locate-id to the later locates and reads for the same question, and you get two things:
  • Something new each time. A later locate leaves out the pages the id already showed and the ones read under it, and says how many it left out.
  • Fewer dead ends. The locator is told which pages were read without finding the answer, so it looks elsewhere.
Later locates name only what is still missing and reuse the id’s question; the reads a reply names already carry the id. Each question gets its own, so a new task, a parallel one or a sub-agent never inherits another’s. ndi run-sql takes no locate id: tables are never left out. A locate shows the best pages in full, as the opening of NDI’s agent’s task does; --pointer names each page by its opening lines instead, as a task’s later locates should, so page text does not pile up. --prefix DIR and repeatable --path PATH scope a locate, -k N sets how many pieces to name (default 12, at most 24), and --all lists every file of the kind the need names. ndi-locate ... runs ndi locate ...: the reply names commands that way, and each runs as printed.
ndi read-file takes --pages, --component, --lines A-B and --max-chars, and --locate-id to record the read; the text goes to stdout and a one-line footer to stderr. A locate id is kept under ~/.ndi/locate and is gone after six hours unused; an unknown or expired one exits 2: start a new one. See Locate, Read file and Run SQL.

Folder metadata and catalog

Two commands answer questions about the workspace as a whole rather than one document. ndi folder-metadata [DIR ...] describes a folder: how many files it holds, their categories and ingestion status, one line per subfolder, and one page of its files (--names-only prints every path in scope, one per line). ndi catalog lists the metadata catalog’s tables, one per document type with its typed fields; ndi catalog "SELECT ..." runs one read-only SELECT over them. Both print exactly what NDI’s own search agent sees (--json for the full response). The catalog answers inline, with no job and no credits.
See Folder metadata and Catalog.

Drex (Decision Model)

Drex is NDI’s decision model. System One is the topology it runs in: one synchronous call in which Drex answers every question about a state, with no agent loop, job or workspace. The endpoint, SDK resource, CLI command and MCP tool are named systemone after it. ndi systemone makes that call. It needs no workspace and creates no job. Pass the state as text with --state, or as any JSON value with --state-json. --questions is a JSON object of named questions. Any of the three values may be @FILE to read a file or @- to read stdin.
Questions are checked before the call: an unknown type, or a choice or score without criteria, exits 2 with error: --questions: <path>: <message> and sends nothing. The server checks the rest, such as an empty noul, empty criteria, and the limits; its refusal exits 1 with error: 422 [invalid_request] <message> and one - <field>: <message> line per refused field, up to five. The text rendering lists each answer: the probability a noul question is true, the chosen option of a choice with every option’s probability, and the expected level of a score. See Drex (Decision Model).

Jobs

ndi cancel only works on a queued or running job. A job that already finished is refused with 409 job_not_cancellable. -o id prints only the job id. A wait that times out still prints the id so you can ndi job it later. Default HTTP timeout is 900 seconds (--timeout). See Jobs.

Output

For job commands and most other commands, the default prints the full JSON response, so receipts, evidence fields, and snippets are all there. When that response is over $NDI_OUTPUT_LIMIT characters (default 400,000), a compact text rendering prints instead, and stderr says note: output shortened … with the full size and the command that prints all of it. For a job that is ndi job <id> --json, which reads the finished job instead of submitting a new one.
  • --json always gives the full response. --save and --out-dir do too, on the commands that run or read a job. Inline commands such as ndi systemone and ndi catalog take --json only: --save and --out-dir exit with a usage error.
  • ndi parse, ndi job <id> for a parse job, and ndi workspace global-context print their content, not a JSON response.
  • ndi folder-metadata, ndi read-file, ndi run-sql, ndi catalog, and ndi locate print their text rendering by default, whatever the size. Add --json for the full response.
  • NDI_OUTPUT_LIMIT=0 always prints the text rendering. A value that is not a character count is rejected before any request is sent.
Scripts that parse the default text output get JSON whenever the response is under the limit (CLI 0.16.0 and later), except for a parse job and the commands listed above, which always print their text. Set NDI_OUTPUT_LIMIT=0 to keep the text rendering, or switch the script to --json.

Next steps

Parse guide

Modes, pages, spreadsheets, and what the result contains.

Extract guide

JSON Schema extraction and citations.

Search a workspace

Automatic search, QA, and journal-entry testing.

MCP server

The same catalog as tools inside Claude Code, Cursor, or opencode.