Nodes/ComfyUI LLM API/LLM API Chat
ComfyUI Node

LLM API Chat

Send text and images to any OpenAI-compatible LLM without leaving ComfyUI

By lhyliu·Created 4 months ago·Updated 4 months ago· 1
LLM API Chat
  • images
  • response
  • error
provider_profilecustom_text_image
api_baseurl
api_key
api_key_env
model
system_promptYou are a helpful assistant
promptHello
temperature0.60
execution_seed100
filter_thinkingtrue
max_images4
image_presetbalanced
custom_image_max_mb1.5
custom_image_max_side1280

The name is a small lie: this node doesn't run an LLM and it doesn't host an API. It's a client. Give it a key and a model name, it dials out to any OpenAI-compatible chat endpoint and hands the reply back to your workflow as a plain string. If you've ever wanted a GPT, DeepSeek, or Qwen step inside an image pipeline - generate a prompt from a reference image, describe what's in your batch, rewrite metadata before saving - this is the kind of node that does it. It's from a small, brand-new pack (lhyliu/ComfyUI_LLM_API) with zero community footprint yet, so you're a bit of an early adopter here. The upside is the code is short and readable.

Why you'd bother

ComfyUI is increasingly a general graph runner, not just a diffusion engine. Mid-workflow you often want a model to look at something and tell you about it. That's this node's whole job: one STRING output you can wire into any prompt builder, text encoder, or metadata node. Because the model field is free text rather than a hardcoded list, nothing goes stale when OpenAI renames another model - a real advantage over the older ComfyUI-LLM-API pack whose fixed model list people keep complaining about.

How it works

Under the hood it's a thin wrapper around the OpenAI Python SDK (openai>=1.0.0). It builds a standard system + user messages array and posts to a chat.completions endpoint - nothing exotic, which is exactly why it works with anything that speaks the OpenAI protocol. Connect an image and it resizes and re-encodes it into a base64 data URL placed inline in the user message as an image_url content part, the standard vision-API shape. Nothing is uploaded as a file; the image travels as text in the request body. And there's a genuinely thoughtful retry: if the provider answers "failed to process image", the node re-compresses at ~72% and ~51% of the byte budget before giving up.

The inputs that matter

  • provider_profile - a preset list: custom_text_image, custom_text_only, openai, deepseek, qwen_dashscope_cn (Alibaba), doubao_ark_cn (ByteDance), zhipu_glm, minimax_global. Pick a preset and api_baseurl fills itself; pick a custom_* profile and you must type your own base URL. That custom path also means any local server speaking the OpenAI dialect - Ollama, LM Studio, vLLM - works fine.
  • model - free text; type the exact model ID.
  • system_prompt and prompt - your two message slots.
  • api_key_env vs api_key - the security fork. api_key_env names an environment variable (like OPENAI_API_KEY); api_key is a plaintext widget that gets baked into the workflow JSON. Prefer the env var, period.
  • images (optional IMAGE input) - feed a ComfyUI image batch for vision. Heads up: deepseek and minimax_global don't support images and will error out before calling the API.
  • image_preset - how hard each image gets compressed: balanced (1.5 MB, 1280px long side) is the sane default; ocr_high (5 MB / 2048px) for screenshots and UI.
  • filter_thinking (default on) - strips <think>...</think> reasoning blocks from reasoning-style models like DeepSeek R1. Leave it on.

One input to not sweat: execution_seed is not sent to the API - it only perturbs ComfyUI's cache so you can force a re-run. Bump it when you want a fresh answer with identical settings.

Outputs

response (STRING) and error (STRING). On success response holds the model text and error is empty; on failure response is empty and error starts with LLM API Error. The node never hard-crashes the graph - it hands you the error as a string to read.

Install

ComfyUI Manager → search "ComfyUI LLM API", or:

cd ComfyUI/custom_nodes
git clone https://github.com/lhyliu/ComfyUI_LLM_API
cd ComfyUI_LLM_API
pip install -r requirements.txt

Then restart ComfyUI. Dependencies are light: openai, Pillow, numpy - nothing heavy, no model downloads.

The part to slow down on

LLM nodes carry baggage in this ecosystem for a reason: the 2024 ComfyUI_LLMVISION pack shipped fake OpenAI wheels that stole browser credentials and ended in a federal conviction. The lesson isn't "never install an LLM node" - it's that custom nodes run arbitrary code on your machine with no sandbox, so install from repos you trust and eyeball the source. The separate privacy point is subtler: connected images and prompts go to whatever provider you picked, and a plaintext key in api_key lives inside your workflow JSON. Don't share that file or a screenshot of it anywhere. Use api_key_env and keep your key in your environment. If response comes back empty, read the error output - it's designed to tell you exactly what went wrong, key redacted.

CategoryComfyUI LLM API

Inputs (15)

NameTypeDefaultDescription
provider_profileCOMBOcustom_text_image8 options: custom_text_image, custom_text_only, openai, deepseek, qwen_dashscope_cn, doubao_ark_cn, +2
api_baseurlSTRING
api_keySTRING
api_key_envSTRING
modelSTRING
system_promptSTRINGYou are a helpful assistant
promptSTRINGHello
temperatureFLOAT0.600–2
execution_seedINT1000–4294967295
filter_thinkingBOOLEANtrue
max_imagesINT41–16
image_presetCOMBObalanced5 options: fast, balanced, detail, ocr_high, custom
custom_image_max_mbFLOAT1.50.1–32
custom_image_max_sideINT12801–8192
imagesoptIMAGE

Outputs (2)

NameTypeDescription
responseSTRING
errorSTRING