Token Optimizer
Estimated reading: 2 minutes
The Token Optimizer component compresses input text to reduce token usage while preserving the original meaning and key information. Compression is applied based on the configured minimum token threshold and the target content retention percentage.
Note: This Component is currently available as a beta version
Parameters
| Parameter | Description |
|---|---|
| Input Text | Connect the node to specify the text to be evaluated and compressed based on the configured token settings. |
| Minimum Tokens to Compress | Specifies the minimum number of tokens required for compression. If the input contains fewer tokens than the specified value, the text is returned without compression. If the input exceeds the specified value, the entire text is compressed according to the Target Content to Keep setting. |
| Target Content to Keep |
Specifies the percentage of the original information to retain after compression.
For example, a value of 80 aims to retain approximately 80% of the original information while removing redundant or unnecessary text. |
| System Prompt | Optional instructions provided to the compression model to influence how the text is condensed or optimized. |
| Headroom Proxy Base URL* |
The endpoint URL for the Headroom proxy service used to perform or route token compression requests.
Endpoint URL: http://172.26.0.69:8787
|
| Timeout (Seconds) | Maximum wait time for the compression request to complete before the operation times out. Default: 30 seconds. |
| Retry Count | Number of automatic retry attempts if the compression request fails. Default: 1. |
| Delay Between Retries (Seconds) | Wait time between consecutive retry attempts. Default: 1 second. |
| Delay Before Execution (Seconds) | Time to wait before the component starts processing. Default: 0 seconds. |
| Delay After Execution (Seconds) | Time to wait after the component finishes processing. Default: 0 seconds. |
| Continue on Error |
Determines the behavior when an unrecoverable error occurs:
|
Output
| Field | Description |
|---|---|
| Compressed Message | Returns the compressed text. If the input does not meet the minimum token threshold, the original text is returned without compression. |
| Compression Stats | Returns compression statistics in JSON format, including details such as the original token count, compressed token count, tokens saved, and retention ratio. |
Behavior Example: If Minimum Tokens to Compress is set to 1000, content containing fewer than 1000 tokens is returned directly without compression. Content containing more than 1000 tokens is compressed according to the Target Content to Keep percentage.