Nodes/ComfyUI-ZML-Image/ZML_LLM 对话主程序
ComfyUI Node

ZML_LLM 对话主程序

A working LLM call inside ComfyUI, images and all

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_LLM 对话主程序
  • model_config
  • params
  • json_schema
  • input_image
  • 回复内容
  • 图像
  • 请求示例
user_input
system_prompt
json_strategyDeepSeek/通用模式 (json_object)
seed0

ZML_LLM_Chat is the payoff node of the ZML pack's LLM set: the one that actually talks to a language model and gets a reply back into your graph. The rest of the set - the model loader, the parameters node, the JSON schema node - is all setup. This is where the request happens.

The name is slightly misleading in the best way: it doesn't load any model locally and needs no GPU. It calls an OpenAI-compatible API (the pack switched to the openai library in a late-2025 update) using the model_config (LLM_MODEL_CONFIG) that a loader node hands it. So the whole thing is a thin, well-behaved HTTP wrapper around whatever base_url and api_key your loader configured - DeepSeek, OpenAI, a local vLLM/Ollama endpoint, anything speaking that dialect.

The inputs that matter:

  • user_input - the actual prompt, multiline.
  • system_prompt - plain STRING, wire it from the ZML system prompt node or anything else.
  • params - the LLM_PARAMS bundle from the parameters node (temperature, top_p, penalties, timeout).
  • json_strategy - the one you'll fiddle with most. Three modes: DeepSeek/通用 (json_object), OpenAI strict (json_schema), and plain prompt (no enforcement). Pick strict only if your provider actually supports response_format with a schema - OpenAI and some compatible APIs do; others return an error and the node hands you the exception text instead of a crash.
  • json_schema (optional) - feed it the JSON_SCHEMA output from ZML_LLM_JsonSchema and the model will be pushed to return that shape.
  • input_image (optional) - the interesting one. The tooltip says it plainly: supports batch image input. Every image in the batch gets base64-encoded to JPEG and attached as an image_url message part, so you can hand a vision model a whole folder of frames in one call.

Outputs: 回复内容 (the text reply), 图像 (a straight pass-through of whatever you sent in, so the graph can keep the image flowing), and 请求示例 (a JSON dump of the request that was sent - invaluable when an API complains and you want to see exactly what it received).

Where people get burned: the seed. seed only gets sent when it's greater than 0, and not every API honors it, so "same seed, different answer" is normal with some providers. And the streaming response means a request can succeed while the connection drops mid-stream - you'll get whatever partial text arrived, so check your timeout in the params node if long generations keep coming back empty.

Security, briefly, because it matters here specifically: this node sends your text and your images to a third party, and your API key lives in the workflow's node configuration unless you use the V2 loader that reads it from a local JSON file (see ZML_LLM_ModelLoaderV2 - it's the right choice for sharing). The KB's llm-in-comfyui doc makes the point that LLM nodes are the exact shape of thing that gets weaponized once (the LLMVISION incident), so only install packs you're happy to run arbitrary Python from. ZML-Image is a big, open, actively-maintained pack, and this node's code is plain to read - but the habit is worth keeping.

Install via Manager or clone as usual:

cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image

The openai requirement comes from the pack's requirements.txt. Restart ComfyUI and the whole LLM set shows up under ZML 图像 → LLM in the menu (Chinese UI; grab the author's English translation patch if needed).

Categoryimage/ZML_图像/LLM

Inputs (8)

NameTypeDefaultDescription
user_inputSTRING
model_configLLM_MODEL_CONFIG
system_promptSTRING
paramsLLM_PARAMS
json_strategyCOMBODeepSeek/通用模式 (json_object)3 options: DeepSeek/通用模式 (json_object), OpenAI严格模式 (json_schema), 仅提示词 (不强求)
json_schemaoptJSON_SCHEMA
seedoptINT00–2147483647
input_imageoptIMAGE支持 Batch 批量图像输入

Outputs (3)

NameTypeDescription
回复内容STRING
图像IMAGE
请求示例STRING