Nodes/comfyui-llamacpp/llama.cpp Token Count
ComfyUI Node

llama.cpp Token Count

Tokenizes text through llama-server and returns the token count plus optional token or piece details.

By Setmaster·Created 7 months ago·Updated about a month ago· 4
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)

NameTypeDefaultDescription
textSTRINGText to tokenize with the selected llama-server model.
server_urloptSTRINGllama-server URL, or empty for the managed runtime.
modeloptSTRINGOptional exact router model ID.
add_specialoptBOOLEANfalseAdd the model's special boundary tokens.
parse_specialoptBOOLEANtrueRecognize special-token text in the input.
with_piecesoptBOOLEANfalseAsk llama-server to include token pieces.
api_key_envoptSTRINGLLAMACPP_API_KEYEnvironment variable containing the API key.
verify_tlsoptBOOLEANtrueVerify HTTPS certificates.
request_timeoutoptINT301–3600Tokenization deadline in seconds.
connectionoptLLAMACPP_CONNECTIONOptional reusable connection profile.

Outputs (2)

NameTypeDescription
token_countINTNumber of tokens returned by llama-server.
tokens_jsonSTRINGToken IDs or token-piece details as JSON.