Llama.cpp Server Client
Talk to your local llama.cpp server from inside ComfyUI
- response
- raw_response
- error
- status_code
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.
Inputs (70)
| Name | Type | Default | Description |
|---|---|---|---|
| server_url | STRING | http://127.0.0.1:8080 | Base URL of the llama-server instance |
| endpoint | COMBO | completion | API endpoint to use |
| prompt | STRING | The prompt text for completion/chat | |
| api_keyopt | STRING | API key for authentication (if required) | |
| timeoutopt | INT | 6001–3600 | Request timeout in seconds |
| n_predictopt | INT | -1-1–100000 | Number of tokens to predict (-1 = infinity) |
| temperatureopt | FLOAT | 0.800–10 | Sampling temperature |
| top_kopt | INT | 400–1000 | Top-k sampling |
| top_popt | FLOAT | 0.950–1 | Top-p (nucleus) sampling |
| min_popt | FLOAT | 0.050–1 | Min-p sampling |
| seedopt | INT | -1-1–2147483647 | Random seed (-1 for random) |
| dynatemp_rangeopt | FLOAT | 0.000–5 | Dynamic temperature range |
| dynatemp_exponentopt | FLOAT | 1.000.1–10 | Dynamic temperature exponent |
| xtc_probabilityopt | FLOAT | 0.000–1 | XTC probability |
| xtc_thresholdopt | FLOAT | 0.100–1 | XTC threshold |
| repeat_penaltyopt | FLOAT | 1.100.1–5 | Repetition penalty |
| repeat_last_nopt | INT | 64-1–2048 | Last n tokens for repetition penalty |
| presence_penaltyopt | FLOAT | 0.00-2–2 | Presence penalty |
| frequency_penaltyopt | FLOAT | 0.00-2–2 | Frequency penalty |
| dry_multiplieropt | FLOAT | 0.000–5 | DRY sampling multiplier |
| dry_baseopt | FLOAT | 1.751–5 | DRY sampling base value |
| dry_allowed_lengthopt | INT | 21–100 | DRY allowed length |
| dry_penalty_last_nopt | INT | -1-1–2048 | DRY penalty last n tokens |
| dry_sequence_breakersopt | STRING | ["\n", ":", "\"", "*"] | JSON array of DRY sequence breakers |
| mirostatopt | INT | 00–2 | Mirostat sampling (0=disabled, 1=v1, 2=v2) |
| mirostat_tauopt | FLOAT | 5.00.1–20 | Mirostat target entropy |
| mirostat_etaopt | FLOAT | 0.1000.001–1 | Mirostat learning rate |
| typical_popt | FLOAT | 1.000–1 | Locally typical sampling |
| n_keepopt | INT | 0-1–2048 | Number of tokens to keep from prompt |
| stop_sequencesopt | STRING | [] | JSON array of stop sequences |
| ignore_eosopt | BOOLEAN | false | Ignore end-of-stream token |
| streamopt | BOOLEAN | false | Enable streaming mode |
| n_probsopt | INT | 00–100 | Return top N token probabilities |
| min_keepopt | INT | 00–100 | Minimum tokens to keep in sampler |
| post_sampling_probsopt | BOOLEAN | false | Return post-sampling probabilities |
| return_tokensopt | BOOLEAN | false | Return raw token IDs |
| timings_per_tokenopt | BOOLEAN | false | Include timing information |
| grammaropt | STRING | BNF grammar for constrained generation | |
| json_schemaopt | STRING | JSON schema for constrained generation | |
| logit_biasopt | STRING | [] | JSON array of logit bias modifications |
| cache_promptopt | BOOLEAN | true | Re-use KV cache from previous requests |
| id_slotopt | INT | -1-1–100 | Assign to specific slot (-1 = auto) |
| samplersopt | STRING | ["dry", "top_k", "typ_p", "top_p", "min_p", "xtc", "temperature"] | JSON array defining sampler order |
| t_max_predict_msopt | INT | 00–60000 | Maximum prediction time in milliseconds |
| messagesopt | STRING | [] | JSON array of chat messages (for chat_completions endpoint) |
| system_messageopt | STRING | System message for chat | |
| user_messageopt | STRING | User message for chat | |
| assistant_messageopt | STRING | Assistant message for chat (for prefilling) | |
| max_tokensopt | INT | -1-1–100000 | Maximum tokens in response (OpenAI style) |
| modelopt | STRING | Model name/alias | |
| toolsopt | STRING | [] | JSON array of available tools/functions |
| tool_choiceopt | STRING | auto | Tool choice strategy |
| response_formatopt | STRING | JSON object defining response format | |
| input_textopt | STRING | Input text for embeddings | |
| encoding_formatopt | COMBO | float | Encoding format for embeddings |
| embd_normalizeopt | INT | 2-1–10 | Embedding normalization type |
| contentopt | STRING | Content to tokenize/detokenize | |
| tokensopt | STRING | [] | JSON array of token IDs |
| add_specialopt | BOOLEAN | false | Add special tokens during tokenization |
| parse_specialopt | BOOLEAN | true | Parse special tokens during tokenization |
| with_piecesopt | BOOLEAN | false | Return token pieces with IDs |
| input_prefixopt | STRING | Code prefix for infill | |
| input_suffixopt | STRING | Code suffix for infill | |
| input_extraopt | STRING | [] | JSON array of additional context files |
| queryopt | STRING | Query for reranking | |
| documentsopt | STRING | [] | JSON array of documents to rank |
| top_nopt | INT | 101–1000 | Number of top results to return |
| loraopt | STRING | [] | JSON array of LoRA adapter configurations |
| response_fieldsopt | STRING | [] | JSON array of specific response fields to return |
| image_dataopt | STRING | [] | JSON array of image data objects |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| response | STRING | — |
| raw_response | STRING | — |
| error | STRING | — |
| status_code | INT | — |