Skip to main content
These tools read ingested workspace files. Ingest a file before you use them. Tool answers report credits billed for this call. Treat null as an unknown amount; older stored answers can lack a billing receipt. Low-level job-backed tools normally cost one credit; repeating a run-sql result that an earlier job already paid for costs zero with waiver: "repeat_of_job". duplicate alone does not guarantee a waiver: a result stored by a cancelled or failed job may still be billable. QA tools report their settled job’s credits, which can vary with the work performed. Re-serving a settled tool answer with the same Idempotency-Key reports credits: 0 and waiver: "repeat_of_job", with the response header Idempotent-Replayed: true. A retry after a transient failure can re-execute the tool and is billed when it succeeds; that fresh execution has no replay header. A job returned with Prefer: respond-async uses the job billing contract instead. A typical agent loop:
  1. Find the file. Folder metadata lists a folder and finds files by name. Search results also name files (source_path).
  2. See what is inside. File metadata describes one file: its category, a summary, and its sections or tabs with their own summaries and key terms.
  3. Ask. QA file answers a question about one file; query tables computes across spreadsheets.
To filter files by type and extracted field (every invoice to one customer, every contract that expires this year), query the catalog. When you know what you need but not which file holds it, locate names the pages and table tabs to read; read file reads them and run SQL computes over the tables — the loop NDI’s own search agent runs. Folder metadata, catalog, locate, read file and run SQL have no SDK or MCP method. Call them with the ndi CLI, which prints what NDI’s own agent sees, or over HTTP as below.

File paths

Folder metadata, file metadata, read file, QA file and query tables name a file by its path: the full path relative to the workspace root, exactly as the file was uploaded. It is the same string these return:
  • file_entries[].path from folder metadata
  • items[].path from GET /v1/workspaces/{workspace_id}/files
  • source_path on every search evidence item
  • source_path on every catalog record
file_not_found is final for the path you sent. Retrying it, or guessing variants of it, returns the same error. Find the real path first: call folder metadata with name_contains set to a distinctive part of the file name, and use the path it returns.

Folder metadata

Lists one folder: how many files it holds, their categories and ingestion status, one summary per subfolder, and one page of file entries with their exact paths. Start at / (the workspace root) and descend, or search the whole workspace by name. The CLI command is ndi folder-metadata.
  • directory is relative to the workspace root. / is the root; evidence/doc-7f83 is a folder under it.
  • A call without narrows lists only the folder’s own files, plus a summary per subfolder. Call again with a subfolder to descend.
  • name_contains, category, ingestion_status and kind narrow both the counts and the listing, and search the whole subtree unless you send "recursive": false. name_contains is case-insensitive, and it also finds files whose ingestion failed.
  • Each file_entries[] entry carries the file’s file_id, the same id GET /v1/workspaces/{id}/files returns, so a caller can go on to GET /files/{file_id} without listing the files again. A server from before the field leaves it out.
  • file_entries comes one page_size page at a time, sorted by path. When files_truncated is true, call again with start_after set to the last path you received.
  • A folder with no matches answers with a hint naming the nearest existing folder. A directory that names a file is refused with invalid_request: use file metadata for it.

File metadata

Describes one uploaded file without opening it: its category, a summary, and the parts you can ask about. Pass the file’s path. New native-PDF ingestions also report read_coverage: pages_read, pages_failed, and ocr_used. These describe the published generation, not retry attempts or billing units. A successful native PDF read reports zero failed pages because any page failure fails the entire parse. Whole-parse failures appear as ingestion errors. Missing coverage on older, cached or unsupported parse results means unknown; it does not mean zero pages or no OCR. The same information appears in file metadata by file ID.
  • category and summary describe the file as a whole. summary is the summary of the file’s first section or tab; each component has its own.
  • components lists the file’s sections (documents), tabs (spreadsheets), an image, or a recording. A recording reports duration_ms and speaker_count.
  • key_terms are up to six of a component’s extracted keywords whose role the file states: who a name is, what a date or number marks. Files ingested before key terms existed have none until they are re-ingested with "reingest_unchanged": true.
  • readable means QA file can answer from the component’s text. queryable means it is a table query tables can compute over. Pass a component’s name as component to scope either tool.
  • Send "component": "<name>" to describe only that section or tab. An unknown name is refused with invalid_request listing the valid names.
  • A file that is not ingested yet answers with its ingestion_status and no components. A failed file carries ingestion_error.

File metadata by file ID

When you hold a file id rather than a path, read the same context from the files API: the file summary, keywords and their roles, and per-section or per-sheet detail. The id comes from upload, the file listing, or source_file_id on search evidence.
keywords remains a list of strings. Each entry in keyword_descriptions has keyword and description; description is null when the source does not establish the keyword’s role. Older ingests may have no descriptions. The same fields appear for logical documents and spreadsheet sheets. native_metadata contains properties supplied by the source file, such as a PDF creator. Each entry in sheets[] also has queryable, true when run SQL can read the tab’s rows, and table_name, the name run SQL registers it under. table_name is set for a workbook tab or a converted CSV and is null otherwise, for example on a directly uploaded parquet file. A CSV tab is stored as a partitioned dataset, so its jsonl_path and parquet_path are null even though queryable is true. Ingestion may suffix the registered name to keep names unique; locate gives the registered name.

Catalog

The typed fields ingestion extracted from every document: an invoice’s number, parties, dates and total; a contract’s parties and dates; a report’s title and period. Call it with no sql to list the tables, then run one read-only SELECT (DuckDB dialect) over them. It answers inline: no job and no credits (credits: 0, waiver: "no_job"). The CLI command is ndi catalog.
The answer lists catalog_document, with one row per record, and one table per document type the workspace holds (invoice, contract, report, …) with its typed columns. empty_tables names the types with no records here. They are still queryable; a query over them returns no rows.
  • A record is one document section, spreadsheet tab, recording or JSON section, never one printed line. The entries a listing, register or ledger prints (each credit note in a credit-note report) are not records of their own: the listing is one record. Read it with read file, or query a tab’s rows with run SQL.
  • Every field has a <field>_status column: found, not_found, ambiguous or unexamined. Only found carries a value, so a comparison on the value column leaves out the other three. Money fields have a <field>_currency column.
  • A field that can hold several values (parties, references) has its own table, such as invoice_reference, with one row per value. Filter with EXISTS (... WHERE invoice_reference.record_id = invoice.record_id ...).
  • source_path is the path the other file tools take.
  • Rows are capped. truncated is true when the result had more rows than were returned; narrow the statement, or page it with ORDER BY, LIMIT and OFFSET.
  • A statement that is not a read, or that fails, is refused with invalid_request and the reason. So is a workspace whose catalog is too large to query whole.
  • The catalog shows only records your access labels allow.

Locate

Names the pages and table tabs that hold a piece of information, across every ingested file you may see. It is the locator NDI’s own search agent calls between reads: a decision model rates every file, section and page and names the best k (default 12, at most 24). It is good at where, not at whether: a named page may hold the wrong period or line, so read it before you rely on it.
  • need (up to 400 characters) is what you still need, in a few words: a year, an entity, a line item. question is the whole question it is part of; omit it and the need is the whole question.
  • path_prefix and paths narrow the files. A path you cannot see or that does not exist is refused with file_not_found.
  • text is the reply as NDI’s agent reads it, with each piece’s read named as an ndi read-file command (the ndi CLI runs every command the text names as printed). pages, tables and population carry the same findings: a paged piece is page number; otherwise it is lines line_start–line_end of the file’s text. population is set when the question needs every file of a kind (each invoice, every contract); send "every": true to ask for that list. population_unrated above 0 means the list is incomplete: narrow the need to a folder, kind or period.
  • Locate is stateless. To be shown something new, send back the pieces you were offered as exclude (path, number, component) and what you read as already_read (path with pages, a line_start–line_end span, or neither for the whole file); up to 1,000 of each. The ndi CLI does this for you. A call that leaves out nothing is your task’s opening: the locator rates more files for it.
  • text gives the best pages in full (as above). Send "pointer": true to name every piece by its opening lines instead, starting Located for: <need>: a task’s later locates do, so page text does not pile up in an agent’s context.
  • upstream_unavailable means the decision model is down: retry later. invalid_request with “not configured” means the deployment has no locator. Locate runs on NDI-managed workspace storage only; a workspace in your own bucket answers invalid_request.
The CLI command is ndi locate. It keeps exclude and already_read for you under a locate id, which it prints first:

Read file

Returns the text of one ingested file: the whole file, one component (a tab or section, as file metadata lists it), some pages (1-based; spreadsheets have none), or the lines line_start–line_end of that text. A file with several components comes back concatenated, each under a one-line header.
  • max_chars (default 200,000, at most 1,000,000) bounds content; truncated says it was cut, and components_omitted names what did not fit.
  • A line range answers line_start, line_end and the whole text’s line_count; when it starts inside a table, table gives that table’s header so the rows read with their column names.
  • sql_tables names the run SQL tables that hold the rows of long PDF tables in the returned text: count or total those rows there. A spreadsheet or CSV tab is not listed here; its table name is sheets[].table_name in file metadata by file ID, or tables[].sql_table from locate.
  • Images are refused with unsupported_file_type: ask them with QA file.

Run SQL

Runs one read-only SELECT (DuckDB dialect) over the workspace’s tables. Each queryable tab is a table under the name locate gives as tables[].sql_table; file metadata by file ID gives it as sheets[].table_name for workbook tabs and converted CSVs; joins across files are ordinary SQL joins. There is no agent in the loop: write the statement yourself, or use query tables to ask in words.
  • result previews the rows (rows, columns, row_count; preview_truncated when the preview is cut). The whole result is retained: result_citation.result_file.download_url fetches it as parquet.
  • result.handle (res_…) is a table in your next statement: join it, aggregate it, or page it with LIMIT/OFFSET. A handle resolves only in the workspace that returned it, and only while you see the same tables. A repeated statement is answered from the stored result (duplicate: true) and is not billed once an earlier run of it has been billed; the first run costs one credit.
  • A statement that is not a read, or that names a table that is not registered, is refused with invalid_request naming the rule and the tables you may read.
The CLI commands are ndi read-file and ndi run-sql:

QA file

Ask a natural-language question of one uploaded file: a document, a workbook, an image, or a recording. For a question across several spreadsheets, use query tables.
For a document, each citation is a verbatim passage the engine took from the file. For a spreadsheet or CSV, the snippet is the matching rows as the engine read them, written as JSON objects (one per row, keyed by column name), so it is not text you can find byte for byte in the uploaded file. A snippet is cut at 500 characters, so a long one may end mid-row and not parse as JSON. There may be several citations, or none: an answer the engine assembled by searching the document rather than reading one passage has nothing to quote, and says so by citing nothing. A citation carries a locator only when the engine located the passage as it read. Otherwise locator is null and the citation names the file, not a span inside it. To place one of those, pass its snippet to ground against the same path. Billing depends on the engine that answered. A question answered from one piece of content is not billed: one text section or transcript (recursive_llm), or one image, page or figure (vision), including a question scoped with component. A question about a table, or across several parts (engine is agent), bills one credit per agent step; the job’s usage shows the total. QA file continues after an HTTP disconnect. Current Python and TypeScript SDKs submit a durable job and poll it; qa_file still returns QaFileResponse, and they accept direct answers from older servers. Omit Prefer and the request waits for the original answer response; if your client’s own timeout fires first, the run keeps going and its answer is kept on the job. For direct HTTP integrations, send Prefer: respond-async with a stable Idempotency-Key: the response is a Job (202 while pending, 200 when terminal) with a Location header pointing to GET /v1/jobs/{job_id}. Retry a lost response with the same key and body to recover the same job and its answer. POST /v1/jobs/{job_id}/cancel stops a run and takes an optional JSON body {"reason": "..."} to record why. DELETE /v1/jobs/{job_id} also cancels a queued or running job before hiding it.

Structured answers

Pass output_schema, a JSON Schema (or, in Python, a Pydantic model class), to get the answer as JSON. Every engine honors it: the agent and the recursive reader are checked and corrected, and a vision answer that misses the schema is reshaped from what the model read. On success answer is the JSON text and structured_answer the parsed value. A field the source does not state comes back null, whatever type the schema gives it. If the answer still misses, the call still succeeds and structured_answer is null. The schema root must be an object, and pattern / patternProperties are refused (state a format in description), as are a recursive $ref and unevaluatedProperties / unevaluatedItems.

Errors

  • file_not_ingested — ingest first
  • invalid_request — qa_file on a derived output path, an unknown or ambiguous component, or a component with no content it can answer about; also an image (or rendered page) that cannot be decoded or exceeds the image safety limit, which is refused before inference and is not retryable