LiteLLMCompletionPrePend
The completion node with a system-prompt slot bolted on front
- model
- messages
- Model
- Messages
- Completion
- Usage
LiteLLMCompletionPrePend is LiteLLMCompletion with one extra text box in front of it. That's the whole diff. Its handler takes your pre_prompt, joins it to your prompt with a newline, and passes the result down to the plain completion handler. Nothing else changes - same model handling, same caching, same retries, same outputs.
So why does it exist? Because in a graph UI, the "always say this before every prompt" text is a separate concern from the per-run prompt. You get a stable place for your standing instructions - "You are a senior prompt engineer. Return only JSON." - while the prompt field stays free for the actual request. It's a small quality-of-life split, and once you've built workflows with it, you'll miss it on the plain node.
The inputs
Everything LiteLLMCompletion takes, plus:
pre_prompt(multiline) - prepended to the prompt with a newline before the call.model-LITELLM_MODELfrom a provider node.prompt(multiline),max_tokens(250),temperature/top_p(0.5),frequency_penalty/presence_penalty(0),reasoning_effort- the usual dials.messages(optional) - conversation history to continue.use_cached_response(optional) - replay the cached result.
Outputs: Model, Messages, Completion, Usage - identical to the base node.
How the prepending works
In the code it's one line: kwargs["prompt"] = f"{pp}\n{kwargs['prompt']}". The combined string becomes a single user message. That's worth knowing because it's not a system message and it's not two messages - it's one message where the instruction happens to come first. For most models that's fine and even preferable, but if you were expecting true system-role separation (some models behave differently when told "system: ..."), you won't get it here; use the messages input with a proper role instead.
Installing
It's part of ComfyUI_LiteLLM. ComfyUI Manager, search "ComfyUI_LiteLLM", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Hopping-Mad-Games/ComfyUI_LiteLLM
cd ComfyUI_LiteLLM
pip install -r requirements.txt
Restart, set a provider key, and it's under ETK/LLM/LiteLLM.
Where people get burned
The trap is thinking the pre-prompt and prompt are sent as separate messages with different roles. They're not - it's a string concatenation with a newline. If you're debugging weird model behavior and you know the instruction text is in the call, check whether your model cares about message roles: if it does, splice your system text in via the messages input instead. Second, the same stale-model gotcha applies - the default is the ancient anthropic/claude-3-haiku-20240307, and a "model not found" error on a fresh install is the dropdown lying to you. Swap in a current model from LiteLLMModelProviderAdv or LiteLLMCustomEndpointProvider. And remember the cost reality: prepending instructions to every call means those tokens are billed on every single call. Keep the standing text tight, or you're paying for the same essay on repeat.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| model | LITELLM_MODEL | anthropic/claude-3-haiku-20240307 | — |
| max_tokens | INT | 2501–10000000000 | — |
| temperature | FLOAT | 0.500–1 | — |
| top_p | FLOAT | 0.500–1 | — |
| frequency_penalty | FLOAT | 0.00 | — |
| presence_penalty | FLOAT | 0.00 | — |
| reasoning_effort | COMBO | low | 3 options: low, medium, high |
| pre_prompt | STRING | pre | — |
| prompt | STRING | prompt | — |
| messagesopt | LLLM_MESSAGES | — | |
| use_cached_responseopt | BOOLEAN | false | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| Model | LITELLM_MODEL | — |
| Messages | LLLM_MESSAGES | — |
| Completion | STRING | — |
| Usage | STRING | — |