ComfyUI Node
llama.cpp Token Count
Tokenizes text through llama-server and returns the token count plus optional token or piece details.
llama.cpp Token Count
- connection
- token_count
- tokens_json
◄text►
◄server_url►
◄model►
◄add_specialfalse►
◄parse_specialtrue►
◄with_piecesfalse►
◄api_key_envLLAMACPP_API_KEY►
◄verify_tlstrue►
◄request_timeout30►
CategoryLlamaCpp
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Text to tokenize with the selected llama-server model. | |
| server_urlopt | STRING | llama-server URL, or empty for the managed runtime. | |
| modelopt | STRING | Optional exact router model ID. | |
| add_specialopt | BOOLEAN | false | Add the model's special boundary tokens. |
| parse_specialopt | BOOLEAN | true | Recognize special-token text in the input. |
| with_piecesopt | BOOLEAN | false | Ask llama-server to include token pieces. |
| api_key_envopt | STRING | LLAMACPP_API_KEY | Environment variable containing the API key. |
| verify_tlsopt | BOOLEAN | true | Verify HTTPS certificates. |
| request_timeoutopt | INT | 301–3600 | Tokenization deadline in seconds. |
| connectionopt | LLAMACPP_CONNECTION | Optional reusable connection profile. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| token_count | INT | Number of tokens returned by llama-server. |
| tokens_json | STRING | Token IDs or token-piece details as JSON. |