> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ndi.nace.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Read files and ask questions

> Folder metadata, file metadata, read-file, and qa-file

These tools are inline (not jobs) except where noted. They read ingested
workspace files.

## Folder and file metadata

<Tabs>
  <Tab title="Python">
    ```python theme={"dark"}
    from ndi_sdk import NdiClient

    with NdiClient() as client:
        workspace_id = "550e8400-e29b-41d4-a716-446655440001"
        folder = client.tools.folder_metadata(workspace_id, directory="reports/")
        print(folder)
        meta = client.tools.file_metadata(workspace_id, path="reports/report.pdf")
        print(meta)
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={"dark"}
    import { NdiClient } from "ndi-sdk";

    const client = new NdiClient();
    const workspaceId = "550e8400-e29b-41d4-a716-446655440001";
    const folder = await client.tools.folderMetadata(workspaceId, { directory: "reports/" });
    const meta = await client.tools.fileMetadata(workspaceId, { path: "reports/report.pdf" });
    console.log(folder, meta);
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={"dark"}
    curl -s -X POST "$NDI_BASE_URL/v1/workspaces/$WS/tools/folder-metadata" \
      -H "X-API-Key: $NDI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"directory":"reports/"}'

    curl -s -X POST "$NDI_BASE_URL/v1/workspaces/$WS/tools/file-metadata" \
      -H "X-API-Key: $NDI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"path":"reports/report.pdf"}'
    ```
  </Tab>
</Tabs>

`folder_metadata` is an **offset** page (`start_after` / `page_size`), not a
cursor list. See [Pagination](/concepts/pagination).

## Read file

Returns extracted text for a path. Optional `pages` and `max_chars`.

```python theme={"dark"}
from ndi_sdk import NdiClient

with NdiClient() as client:
    workspace_id = "550e8400-e29b-41d4-a716-446655440001"
    page = client.tools.read_file(
        workspace_id,
        path="reports/report.pdf",
        pages=[1],
        max_chars=4000,
    )
    print(page.content)
```

## QA file

Ask a natural-language question of **one uploaded document, image, or
recording**. Do not use it for Excel — use [query tables](/guides/query-tables).

```python theme={"dark"}
from ndi_sdk import NdiClient

with NdiClient() as client:
    workspace_id = "550e8400-e29b-41d4-a716-446655440001"
    answer = client.tools.qa_file(
        workspace_id,
        path="reports/report.pdf",
        query="What were total liabilities at year end?",
    )
    print(answer.answer)
    for citation in answer.citations or []:
        print(citation)
```

## Errors

* **`file_not_ingested`** — ingest first
* **`invalid_request`** — `qa_file` on a spreadsheet path
