Nodes/comfyui-llamacpp-client/Llama.cpp Server Client
ComfyUI Node

Llama.cpp Server Client

Talk to your local llama.cpp server from inside ComfyUI

By fidecastro·Created about a year ago·Updated about a year ago· 9
Llama.cpp Server Client
    • response
    • raw_response
    • error
    • status_code
    server_urlhttp://127.0.0.1:8080
    endpointcompletion
    prompt
    api_key
    timeout600
    n_predict-1
    temperature0.80
    top_k40
    top_p0.95
    min_p0.05
    seed-1
    dynatemp_range0.00
    dynatemp_exponent1.00
    xtc_probability0.00
    xtc_threshold0.10
    repeat_penalty1.10
    repeat_last_n64
    presence_penalty0.00
    frequency_penalty0.00
    dry_multiplier0.00
    dry_base1.75
    dry_allowed_length2
    dry_penalty_last_n-1
    dry_sequence_breakers["\n", ":", "\"", "*"]
    mirostat0
    mirostat_tau5.0
    mirostat_eta0.100
    typical_p1.00
    n_keep0
    stop_sequences[]
    ignore_eosfalse
    streamfalse
    n_probs0
    min_keep0
    post_sampling_probsfalse
    return_tokensfalse
    timings_per_tokenfalse
    grammar
    json_schema
    logit_bias[]
    cache_prompttrue
    id_slot-1
    samplers["dry", "top_k", "typ_p", "top_p", "min_p", "xtc", "temperature"]
    t_max_predict_ms0
    messages[]
    system_message
    user_message
    assistant_message
    max_tokens-1
    model
    tools[]
    tool_choiceauto
    response_format
    input_text
    encoding_formatfloat
    embd_normalize2
    content
    tokens[]
    add_specialfalse
    parse_specialtrue
    with_piecesfalse
    input_prefix
    input_suffix
    input_extra[]
    query
    documents[]
    top_n10
    lora[]
    response_fields[]
    image_data[]

    What it is

    LlamaCppClient is not a text-generation node in the way you're probably picturing. It doesn't load a model, it doesn't run inference, and it doesn't need any GGUF weights sitting anywhere near ComfyUI. It's an HTTP client - one node that knows how to talk to every endpoint llama-server (the actual server binary from llama.cpp) exposes: completions, chat, embeddings, tokenize/detokenize, template testing, code infill, and reranking. If you've been running a local LLM through llama.cpp for anything else - a coding assistant, a chatbot, a RAG pipeline - this is the node that lets ComfyUI join that party instead of you spinning up a separate Ollama node or paying for a cloud API.

    Where this fits in a real workflow: writing detailed prompts by hand for modern LLM-conditioned image models (Flux, Z-Image, anything reading natural-language instructions instead of tags) is tedious, and the community has largely moved to having an LLM write the prompt instead - it's become common enough that dedicated prompt-writing node packs now draw real attention on release. LlamaCppClient is the DIY version of that: point it at a llama-server you're already running, feed it a rough idea, and wire its text output into whatever downstream node needs a string - a CLIP/T5 text encode, a caption field, a batch of variations.

    How it works

    The node builds a request to whichever llama-server endpoint you pick and ships back whatever comes out. That's it - the "intelligence" lives entirely on your llama-server instance and whatever GGUF model it loaded, not in this node. Because it mirrors the server's own API almost parameter-for-parameter, it exposes essentially everything: temperature and top-k/top-p/min-p for basic sampling, DRY and XTC and Mirostat for the fancier anti-repetition and coherence tricks, JSON-schema and BNF grammar constraints for forcing structured output, chat message fields for multi-turn conversations, and separate parameter groups for embeddings, tokenization, infill, and reranking. It's genuinely comprehensive - the tradeoff for that completeness is a very long, very dense node.

    Inputs and outputs that actually matter

    You only need three fields to get started: server_url (default http://127.0.0.1:8080, wherever your llama-server is listening), endpoint (an 8-way choice - completion, chat_completions, embeddings, tokenize, detokenize, apply_template, infill, reranking), and prompt, the text you're sending in. Everything else in the optional list is a specific llama-server parameter - temperature, n_predict, seed, and friends for basic generation control - that you only touch once you know you need it. One trap worth knowing up front: several optional fields (stop_sequences, messages, tools, logit_bias, dry_sequence_breakers, and others) are raw JSON typed into a plain text box, not structured widgets, so a stray comma or missing bracket will break the request.

    On the way out you get four outputs: response (the clean text, what you actually want most of the time), raw_response (the full JSON the server returned, useful if you need a field the node doesn't surface directly), error (empty on success, populated with a real message on failure), and status_code (the HTTP code, handy for branching a workflow on success/failure).

    Installing it

    Through ComfyUI Manager: search for "comfyui-llamacpp-client" and install. Manually: cd ComfyUI/custom_nodes && git clone https://github.com/fidecastro/comfyui-llamacpp-client.git, then cd comfyui-llamacpp-client && pip install -r requirements.txt, then restart ComfyUI - it'll show up under AI/LlamaCpp. That's the easy part. The real prerequisite is llama-server itself, running separately - this node ships zero model-running code. Grab llama.cpp, build or download llama-server, and start it with a GGUF model: ./llama-server -m your-model.gguf -c 4096 --host 0.0.0.0 --port 8080. If you want embeddings or reranking to work, you need to start it with --embedding and/or --reranking respectively - the endpoints those flags gate will error out otherwise.

    Where people get stuck

    Connection-refused errors almost always mean llama-server isn't running, or is running but not reachable at the server_url you typed - check the host/port match, especially if the server's on another machine and you left the default 127.0.0.1. Timeouts on long generations are just the timeout parameter being too low for how much you asked for (uncapped n_predict can run a while). "Endpoint not working" is almost always a missing server flag - the README calls this out directly, and it's the single most common gotcha with a server this configurable. And since one node serves eight different endpoints, it's easy to fill in fields for the wrong one - setting messages while endpoint is still completion, say. Match your fields to your endpoint choice and most of the confusion goes away.

    CategoryAI/LlamaCpp

    Inputs (70)

    NameTypeDefaultDescription
    server_urlSTRINGhttp://127.0.0.1:8080Base URL of the llama-server instance
    endpointCOMBOcompletionAPI endpoint to use
    promptSTRINGThe prompt text for completion/chat
    api_keyoptSTRINGAPI key for authentication (if required)
    timeoutoptINT6001–3600Request timeout in seconds
    n_predictoptINT-1-1–100000Number of tokens to predict (-1 = infinity)
    temperatureoptFLOAT0.800–10Sampling temperature
    top_koptINT400–1000Top-k sampling
    top_poptFLOAT0.950–1Top-p (nucleus) sampling
    min_poptFLOAT0.050–1Min-p sampling
    seedoptINT-1-1–2147483647Random seed (-1 for random)
    dynatemp_rangeoptFLOAT0.000–5Dynamic temperature range
    dynatemp_exponentoptFLOAT1.000.1–10Dynamic temperature exponent
    xtc_probabilityoptFLOAT0.000–1XTC probability
    xtc_thresholdoptFLOAT0.100–1XTC threshold
    repeat_penaltyoptFLOAT1.100.1–5Repetition penalty
    repeat_last_noptINT64-1–2048Last n tokens for repetition penalty
    presence_penaltyoptFLOAT0.00-2–2Presence penalty
    frequency_penaltyoptFLOAT0.00-2–2Frequency penalty
    dry_multiplieroptFLOAT0.000–5DRY sampling multiplier
    dry_baseoptFLOAT1.751–5DRY sampling base value
    dry_allowed_lengthoptINT21–100DRY allowed length
    dry_penalty_last_noptINT-1-1–2048DRY penalty last n tokens
    dry_sequence_breakersoptSTRING["\n", ":", "\"", "*"]JSON array of DRY sequence breakers
    mirostatoptINT00–2Mirostat sampling (0=disabled, 1=v1, 2=v2)
    mirostat_tauoptFLOAT5.00.1–20Mirostat target entropy
    mirostat_etaoptFLOAT0.1000.001–1Mirostat learning rate
    typical_poptFLOAT1.000–1Locally typical sampling
    n_keepoptINT0-1–2048Number of tokens to keep from prompt
    stop_sequencesoptSTRING[]JSON array of stop sequences
    ignore_eosoptBOOLEANfalseIgnore end-of-stream token
    streamoptBOOLEANfalseEnable streaming mode
    n_probsoptINT00–100Return top N token probabilities
    min_keepoptINT00–100Minimum tokens to keep in sampler
    post_sampling_probsoptBOOLEANfalseReturn post-sampling probabilities
    return_tokensoptBOOLEANfalseReturn raw token IDs
    timings_per_tokenoptBOOLEANfalseInclude timing information
    grammaroptSTRINGBNF grammar for constrained generation
    json_schemaoptSTRINGJSON schema for constrained generation
    logit_biasoptSTRING[]JSON array of logit bias modifications
    cache_promptoptBOOLEANtrueRe-use KV cache from previous requests
    id_slotoptINT-1-1–100Assign to specific slot (-1 = auto)
    samplersoptSTRING["dry", "top_k", "typ_p", "top_p", "min_p", "xtc", "temperature"]JSON array defining sampler order
    t_max_predict_msoptINT00–60000Maximum prediction time in milliseconds
    messagesoptSTRING[]JSON array of chat messages (for chat_completions endpoint)
    system_messageoptSTRINGSystem message for chat
    user_messageoptSTRINGUser message for chat
    assistant_messageoptSTRINGAssistant message for chat (for prefilling)
    max_tokensoptINT-1-1–100000Maximum tokens in response (OpenAI style)
    modeloptSTRINGModel name/alias
    toolsoptSTRING[]JSON array of available tools/functions
    tool_choiceoptSTRINGautoTool choice strategy
    response_formatoptSTRINGJSON object defining response format
    input_textoptSTRINGInput text for embeddings
    encoding_formatoptCOMBOfloatEncoding format for embeddings
    embd_normalizeoptINT2-1–10Embedding normalization type
    contentoptSTRINGContent to tokenize/detokenize
    tokensoptSTRING[]JSON array of token IDs
    add_specialoptBOOLEANfalseAdd special tokens during tokenization
    parse_specialoptBOOLEANtrueParse special tokens during tokenization
    with_piecesoptBOOLEANfalseReturn token pieces with IDs
    input_prefixoptSTRINGCode prefix for infill
    input_suffixoptSTRINGCode suffix for infill
    input_extraoptSTRING[]JSON array of additional context files
    queryoptSTRINGQuery for reranking
    documentsoptSTRING[]JSON array of documents to rank
    top_noptINT101–1000Number of top results to return
    loraoptSTRING[]JSON array of LoRA adapter configurations
    response_fieldsoptSTRING[]JSON array of specific response fields to return
    image_dataoptSTRING[]JSON array of image data objects

    Outputs (4)

    NameTypeDescription
    responseSTRING
    raw_responseSTRING
    errorSTRING
    status_codeINT