IF LLM🎨
One Node to Run Every LLM You Own (and a Bunch You Don't)
- images
- mask
- Omni
- question
- response
- negative
- omni
- generated_images
- mask
This is the node the whole pack is built around - the one that made r/comfyui sit up when IF-LLM hit the front page. One widget that talks to Ollama, llama.cpp, LM Studio, KoboldCpp, and text-generation-webui running on your box, plus hosted APIs from OpenAI, Anthropic, Google Gemini, Groq, Mistral, xAI, and DeepSeek, and even downloads Transformers models straight from Hugging Face. Thirteen providers, one interface, and it's also a vision model: feed it an image and it'll describe, critique, or turn it into a prompt.
The most popular way people actually use it is as a prompt engineer in the graph. You drop in a rough idea, the LLM writes you a proper prompt, and you route the response output into your CLIP text encode. The pack ships presets specifically for that - profiles, embellishments, style prompts, and negative prompts loaded from JSON files under IF_AI/presets/ - which is why the author also publishes tuned Ollama models like impactframes/llama3_ifai_sd_prompt_mkr_q4km.
How it works
You pick a llm_provider and type the exact llm_model name (no dropdown of your stuff - the pack validates the string against the provider's list at run time). Then user_prompt is the message. The node assembles a system prompt from prime_directives (the field's tooltip just calls it "the system prompt for the LLM") or from a named profiles entry, layers on whatever embellish_prompt, style_prompt, and neg_prompt you chose from the preset dropdowns, applies a stop_string, and fires the request.
The strategy dropdown changes what you get back:
normal- the text answer you expect.omost- regional canvas prompting, paired with an omost model likeimpactframes/dolphin_llama3_omost. Instead of one prompt it emits a multi-region layout, returned through theomnioutput.create,edit,variations- the provider generates actual images (DALL·E, Gemini, that family), which come back ongenerated_images.
There's also an auto mode that batch-generates prompts from a folder of images, which is where IF_LLM_LoadImagesS feeds in.
Inputs and outputs that matter
Don't touch most of the optional fields. The ones you'll actually set:
llm_provider,llm_model,user_prompt- the core of every run.max_tokens- caps the response (default 2048).random/seed- toggles temperature-based sampling against a fixed seed for reproducible runs.keep_alive- keep the model resident between calls (faster, eats VRAM) or unload it.images- connect a batch here to use a vision model.external_api_key- only if you don't want it picked up from env or.env.
Outputs: question (the fully assembled prompt that was actually sent - great for debugging), response (the answer you wire into your sampler or a display node), negative (the negative-prompt text for image generation), plus omni, generated_images, and mask for the special strategies. Note the tooltip on attention (sdpa / flash_attention_2 / xformers) - that's only relevant on the Transformers provider.
Installing and setting up
Install once for the whole pack - ComfyUI Manager (search "IF_LLM"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/if-ai/ComfyUI-IF_LLM
then restart. The README is explicit about the recommended backend: install Ollama. That's why the default port is 11434. Pull something small to start:
ollama run llama3.2
For hosted APIs, set env vars with the exact names - OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY, GROQ_API_KEY, MISTRAL_API_KEY, XAI_API_KEY - or drop them in a .env file. And before installing: the README warns this pack conflicts with IF_AI_tools, so remove that first or the two collide.
Troubleshooting
- "Invalid LLM model selected" - the model name doesn't match what the provider reports. Use the pack's
IF_LLM_ListModelsnode to get the exact string, tags and all. - Transformers provider seems to hang the first run - it's downloading the model from Hugging Face, which can be gigabytes. That's expected, not a bug.
- Ollama connections failing -
ollama serverunning? Right port? Wrongbase_ipif it's on another machine? - API provider returns errors - keys must use those exact env var names; the
external_api_keyfield overrides them when filled.
The honest take: this node is impressively broad, and the price of that breadth is that some knobs are fiddly (the model-name validation being the main one). Once you've got one provider working, the rest of the pack slots in around it.
Inputs (26)
| Name | Type | Default | Description |
|---|---|---|---|
| llm_provider | COMBO | transformers | 13 options: transformers, llamacpp, ollama, kobold, lmstudio, textgen, +7 |
| llm_model | COMBO | 0 options: | |
| base_ip | STRING | localhost | — |
| port | STRING | 11434 | — |
| user_prompt | STRING | — | |
| imagesopt | IMAGE | — | |
| strategyopt | COMBO | normal | 5 options: normal, omost, create, edit, variations |
| maskopt | MASK | — | |
| prime_directivesopt | STRING | The system prompt for the LLM. | |
| profilesopt | COMBO | None | The pre-defined system_prompt from the json profile file on the presets folder you can edit or make your own will be listed here. |
| embellish_promptopt | COMBO | The pre-defined embellishment from the json embellishments file on the presets folder you can edit or make your own will be listed here. | |
| style_promptopt | COMBO | The pre-defined style from the json style_prompts file on the presets folder you can edit or make your own will be listed here. | |
| neg_promptopt | COMBO | The pre-defined negative prompt from the json neg_prompts file on the presets folder you can edit or make your own will be listed here. | |
| stop_stringopt | COMBO | Specifies a string at which text generation should stop. | |
| max_tokensopt | INT | 20481–8192 | Maximum number of tokens to generate in the response. |
| randomopt | BOOLEAN | false | Toggles between using a fixed seed or temperature-based randomness. |
| seedopt | INT | 0 | Random seed for reproducible outputs. |
| keep_aliveopt | BOOLEAN | true | Determines whether to keep the model loaded in memory between calls. |
| clear_historyopt | BOOLEAN | true | Determines whether to clear the history between calls. |
| history_stepsopt | INT | 10 | Number of steps to keep in history. |
| aspect_ratioopt | COMBO | 1:1 | Aspect ratio for the generated images. |
| autoopt | BOOLEAN | false | If true, it generates auto promts based on the listed images click the save Auto settings to set the auto prompt generation file |
| batch_countopt | INT | 1 | Number of images to generate. only for create, edit and variations strategies. |
| external_api_keyopt | STRING | If this is not empty, it will be used instead of the API key from the .env file. Make sure it is empty to use the .env file. | |
| Omniopt | OMNI | Additional input for the selected tool. | |
| attentionopt | COMBO | sdpa | Select attention mechanism on Transformer models. |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| question | STRING | — |
| response | STRING | — |
| negative | STRING | — |
| omni | OMNI | — |
| generated_images | IMAGE | — |
| mask | MASK | — |