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

# TextGenerateV2 - ComfyUI Built-in Node Documentation

> The Generate Text node uses a CLIP model to produce text from a prompt.

The Generate Text node uses a CLIP model to produce text from a prompt. Unlike the older single-attachment node, it accepts growable stacks of images, videos and audio files as extra context, so you can feed a whole reference set in one node. You control the output length, whether sampling is used, and whether the model's own chat template and thinking mode apply.

## Inputs

| Parameter | Description | Data Type | Required | Range |
| - | - | - | - | - |
| `clip` | The CLIP model used to tokenize the prompt and generate the text. | CLIP | Yes | - |
| `prompt` | The prompt that guides the generation. Supports multiple lines and dynamic prompts (default: empty string). | STRING | Yes | - |
| `images` | Growable group of up to 50 images, `image1` through `image50`, used as visual context for the model. | AUTOGROW | No | 0 to 50 images |
| `videos` | Growable group of up to 100 video inputs, `video1` through `video100`. Each video is a batch of frames assumed to be 24 FPS and subsampled to 1 FPS internally. | AUTOGROW | No | 0 to 100 videos |
| `audios` | Growable group of up to 100 audio inputs, `audio1` through `audio100`, used as audio context for the model. | AUTOGROW | No | 0 to 100 audio files |
| `max_length` | Maximum number of tokens to generate (default: 512). | INT | Yes | 1 to 32768 |
| `sampling_mode` | `on` samples the output and reveals the sampling parameters below. `off` generates greedily without random sampling. | DYNAMIC\_COMBO | Yes | `"on"` `"off"` |
| `thinking` | Operate in thinking mode if the model supports it (default: False). | BOOLEAN | No | True or False |
| `use_default_template` | Use the built in system prompt or chat template if the model has one (default: True). Advanced parameter. | BOOLEAN | No | True or False |
| `mtp` | Speculative decoding with the checkpoint's multi-token-prediction head. Has no effect without MTP weights. `"auto"` adapts the draft depth and breadth to the observed token matches and execution cost, `"2"` to `"5"` pin a constant draft depth, and the `tree` modes pin both breadth and depth. Sampled output stays correctly distributed but differs from non-MTP output for the same seed (default: `"auto"`). | COMBO | No | `"auto"` `"off"` `"2"` `"3"` `"4"` `"5"` `"tree2s1"` `"tree2s2"` `"tree3s1"` `"tree4s1m8"` |
| `system_prompt` | Replaces the system prompt in the model's chat template. Ignored when the default template is not used. Connect a STRING input instead of typing in the node (default: empty). | STRING | No | - |

### Sampling Parameters (when `sampling_mode` is `"on"`)

| Parameter | Description | Data Type | Required | Range |
| - | - | - | - | - |
| `temperature` | Controls the randomness of the output. Lower values make the output more predictable, higher values make it more creative (default: 0.7). | FLOAT | Yes | 0.01 to 2.0 |
| `top_k` | Limits the sampling pool to the K most likely next tokens. A value of 0 disables the filter (default: 64). | INT | Yes | 0 to 1000 |
| `top_p` | Nucleus sampling: keeps the smallest set of most likely tokens whose cumulative probability reaches this value (default: 0.95). | FLOAT | Yes | 0.0 to 1.0 |
| `min_p` | Minimum probability a token must reach to stay in the pool (default: 0.05). | FLOAT | Yes | 0.0 to 1.0 |
| `repetition_penalty` | Penalizes tokens that have already been generated to reduce repetition. A value of 1.0 applies no penalty (default: 1.05). | FLOAT | Yes | 0.0 to 5.0 |
| `presence_penalty` | Penalizes new tokens based on whether they have appeared in the text so far, encouraging the model to move to new topics (default: 0.0). | FLOAT | Yes | 0.0 to 5.0 |
| `seed` | Number used to initialize the random number generator for reproducible results (default: 0). | INT | Yes | 0 to 18446744073709551615 |

**Note:** The sampling parameters above only exist when `sampling_mode` is `"on"`. With `"off"` the node generates text without random sampling and the parameters are hidden.

**Note:** When the model's output opens a reasoning block with `<think>`, the node splits it: `generated_text` carries the answer and `thinking` carries the reasoning with the opening tag removed. Otherwise `generated_text` carries everything the model produced and `thinking` is empty. Reasoning that was cut off by `max_length` stays in `generated_text`.

## Outputs

| Output Name | Description | Data Type |
| - | - | - |
| `generated_text` | The text the model generated, with any reasoning block separated out into the `thinking` output. | STRING |
| `thinking` | The reasoning block the model produced, with the opening `<think>` tag removed. Empty when the model produced no reasoning block. | STRING |

> This documentation was AI-generated. If you find any errors or have suggestions for improvement, please feel free to contribute! [Edit on GitHub](https://github.com/Comfy-Org/embedded-docs/blob/main/comfyui_embedded_docs/docs/TextGenerateV2/en.md)

***

**Source fingerprint (SHA-256):** `b61210726faa495a342a5eaaebe64f800ec1d2af4e2fc1321d8c3d7c594bd9ca`


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