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

# Generate File

> Builds **one downloadable file** from either AI instructions or raw structured data.

Builds **one downloadable file** from either AI instructions or raw structured data. Display name **"Generate File"**. On by default for new agents.

`format: html` is a static HTML **file**, not an interactive task-feed widget. For a live scorecard in the feed use `app_tool`; for a rendered view of prior step JSON use `custom_interface`.

## When to use it (vs `app_tool` vs `custom_interface` vs `python_code_tool`)

| Need | Tool |
| - | - |
| Downloadable CSV / XLSX / PDF / DOCX / MD / HTML / JSON | `generate_file` |
| Interactive UI in the task feed | `app_tool` |
| Display-only HTML of prior step outputs | `custom_interface` |
| Custom computation whose feed output is markdown | `python_code_tool` |

## Modes

**AI generation** — pass `instructions` + `format`. The model writes the file. Supported: `html`, `md`, `csv`, `xlsx`, `pdf`, `docx`. Do **not** use this when you already have structured data; it wastes an LLM call and can distort values.

**Direct conversion** — pass `content` (usually a `${VAR_N}` from `structured_data_extraction`, `python_code_tool`, or `postgres_execute_query`) + `format` `csv`, `xlsx`, or `json`. No LLM. Nested extraction metadata is stripped. For `xlsx`, an array of `{sheetName, headers, rows}` becomes a multi-sheet workbook. `json` is conversion-only (requires `content`).

**Verbatim text** — pass `content` + `format` `html` or `md`. The content is written byte-for-byte as the file with no LLM call — use it when the agent has already authored the complete document (e.g. a filled-in template) so the file is created instantly instead of being re-generated. With `file_id`, the content replaces that existing file. HTML still gets its PDF rendering (`pdf_file_id` / `pdf_preview_url`) automatically.

## Inputs

Required: `format`, `filename` (no extension; the tool adds it).

* `instructions` — AI mode.
* `content` — conversion mode; when set, `instructions` is ignored.
* `file_id` — optional UUID of an existing file to overwrite.
* `delimiter` — CSV only: `,` (default), `;`, `|`, tab.

If the user uploaded files and wants a new file from their contents, extract first (`structured_data_extraction` / parsers), then call this tool.

## Output

The generated file (filename, format, storage URL / file id) for download or downstream tools.

## Limits and side effects

* One file per call.
* Uploads to task storage; overwriting via `file_id` replaces that row's contents.
* Repair loops may retry malformed AI output (CSV/XLSX/PDF) within configured bounds.

## Expected errors

* Neither `instructions` nor `content` provided.
* `format: json` without `content`.
* Unknown format, or conversion of data the formatter cannot shape.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.