> ## 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.

# TextGenerate - ComfyUI Built-in Node Documentation

> The TextGenerate node uses a CLIP model to create text based on a user's prompt.

The TextGenerate node uses a CLIP model to create text based on a user's prompt. It can optionally use images, video, or audio as additional context to guide the text generation. You can control the length of the output, enable a thinking mode for supported models, and choose whether to use random sampling with various settings or to generate text without sampling.

## Inputs

### Common Inputs

| Parameter | Description | Data Type | Required | Range |
| - | - | - | - | - |
| `sampling_mode` | Controls whether random sampling is used during text generation. When set to "on", additional sampling parameters become available. When set to "off", the node generates text without random sampling. | DYNAMIC\_COMBO | Yes | `"on"`<br />`"off"` |
| `clip` | The CLIP model used for tokenizing the prompt and generating text. | CLIP | Yes | N/A |
| `prompt` | The text prompt that guides the generation. This field supports multiple lines and dynamic prompts. The default value is an empty string. | STRING | Yes | N/A |
| `image` | An optional image that can be used alongside the text prompt to influence the generated text. | IMAGE | No | N/A |
| `video` | Video frames as an image batch. Assumed to be 24 FPS; subsampled to 1 FPS internally. | IMAGE | No | N/A |
| `audio` | An optional audio input that can be used alongside the text prompt to influence the generated text. | AUDIO | No | N/A |
| `max_length` | The maximum number of tokens the model will generate. The default value is 512. | INT | Yes | 1 to 32768 |
| `thinking` | Operate in thinking mode if the model supports it. The default value is False. | BOOLEAN | No | True or False |
| `use_default_template` | Use the built in system prompt/template if the model has one. The default value is True. This is an 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, `"2"` to `"5"` pin it. Sampled output stays correctly distributed but differs from non-MTP output for the same seed (default: `"auto"`). | COMBO | No | `"auto"`<br />`"off"`<br />`"2"`<br />`"3"`<br />`"4"`<br />`"5"` |
| `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 | N/A |

### 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. The default value is 0.7. | FLOAT | Yes | 0.01 to 2.0 |
| `top_k` | Limits the sampling pool to the top K most likely next tokens. A value of 0 disables this filter. The default value is 64. | INT | Yes | 0 to 1000 |
| `top_p` | Uses nucleus sampling: it keeps the smallest set of most likely tokens whose cumulative probability reaches this value. The default value is 0.95. | FLOAT | Yes | 0.0 to 1.0 |
| `min_p` | Sets a minimum probability threshold for tokens to be considered. The default value is 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. The default value is 1.05. | FLOAT | Yes | 0.0 to 5.0 |
| `seed` | A number used to initialize the random number generator for reproducible results. The default value is 0. | INT | Yes | 0 to 18446744073709551615 |
| `presence_penalty` | Penalizes new tokens based on whether they have appeared in the text so far, encouraging the model to talk about new topics. The default value is 0.0. | FLOAT | No | 0.0 to 5.0 |

**Note:** The sampling parameters above are only active and visible in the node interface when `sampling_mode` is set to "on". When `sampling_mode` is set to "off", no sampling parameters are available and the node generates text without random sampling.

**Note:** When the generated text contains a reasoning block (it opens with `<think>` or the prompt ends with it), the reasoning is returned separately: `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.

## Outputs

| Output Name | Description | Data Type |
| - | - | - |
| `generated_text` | The text generated by the model based on the input prompt and optional image, video, or audio, 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/TextGenerate/en.md)

***

**Source fingerprint (SHA-256):** `80813781c06dfb0c3b59ee72c8bd6ebced69a4de8152de916ebc15153a0757fa`


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