Nodes/comfyui_ai_prompt/AI 提示词生成器
ComfyUI Node

AI 提示词生成器

Make an LLM write your prompt, then hand it straight to KSampler

By Bigesila-B·Created 25 days ago·Updated a day ago· 1
AI 提示词生成器
  • image
  • clip
  • response
  • conditioning
providerOpenAI Responses
urlhttps://api.openai.com/v1
api_key
modelgpt-4o-mini
system_templateYou are a precise image prompt assistant.
questionDescribe the image as a concise generation prompt.
result
encode_clipfalse
direct_modefalse
images[]

Blank canvas syndrome is a real ComfyUI disease. You know the rough idea, but staring at an empty prompt box and sweating out the phrasing is the most boring part of the job. This node is the cure: it calls an actual language model - OpenAI, Anthropic, or a local LM Studio server - has it write the prompt, and can even encode the result into CONDITIONING so it flows straight into your KSampler. Nothing leaves the graph. Your whole pipeline runs on one canvas.

Here's the important part about what it isn't: it's not a diffusion model and it runs no inference locally. It's an HTTP client with nice ComfyUI clothes. An LLM-in-the-graph node - a tool that sits upstream of the sampler and rewrites text - and that pattern is thoroughly mainstream by now. Every generation, it costs you API calls instead of VRAM.

How it works

Pick a provider and the node handles the protocol plumbing. OpenAI Responses appends /responses to your URL, OpenAI Chat uses /chat/completions, Anthropic Messages hits /messages, and LM Studio Compatible expects the standard chat endpoint. It POSTs your system prompt and question, waits (timeout is 120 seconds), and returns the model's text. Attach one or more images in the node's upload area and it base64-encodes them into the request, so vision-capable models can describe a reference image and turn it into a prompt - a classic image-to-prompt captioning flow.

The inputs that actually matter

  • provider - the API protocol. OpenAI Responses is the modern default, but "OpenAI-compatible" usually means Chat Completions, so match this to what your endpoint actually speaks.
  • api_key and model - your key (only needed for hosted providers; local LM Studio usually runs without one) and the exact model ID, like gpt-4o-mini.
  • direct_mode - when off (the default), ComfyUI reuses the result text you've already got instead of re-billing you. When on, every queue run re-calls the API.
  • encode_clip - encode the LLM's output into CONDITIONING through a clip input, so it can feed KSampler's positive or negative directly.

The result field is both an input and an output, and that's the clever bit. Leave direct_mode off, click 生成提示词 to get a draft, edit it to your liking, then queue the workflow - the node reuses your edited text and never makes a second API call. It's a review-then-run loop built into the node. This is the pattern the author recommends, and it's the one that stops your API bill from ballooning. Only when result is empty does a queue run actually reach out to the model. Turn direct_mode on only for automation and batch jobs, and know that every single execution costs you money.

Outputs

  • response - the generated (or reused, or edited) STRING. Wire it to any text input downstream.
  • conditioning - the CONDITIONING from encode_clip, or None if disabled.

Installing it

The pack is called AI Prompt in ComfyUI Manager - search it there, or clone manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Bigesila-B/comfyui_ai_prompt.git
cd comfyui_ai_prompt
python -m pip install -r requirements.txt

Dependencies are just requests, Pillow, and numpy - no models to download, nothing heavy. Then restart ComfyUI and look in the AI 提示词 category. If you're on the Portable build, use its bundled Python (python_embeded/python.exe) for the pip install, or you'll get No module named requests.

Where people get burned

The CLIP input is required when encode_clip is enabled error is the classic: flip encode_clip on without wiring a CLIP model into the clip socket and the run dies. Also watch for the 404 from a doubled /v1 in your URL - give a base address like https://api.openai.com/v1, not one path pasted twice. And the two things this node shares with every API-wrapper in the ecosystem: your api_key rides along in the workflow JSON/PNG metadata (a masked input is not encryption), and your images leave the machine when you send them to a hosted provider. The local LM Studio path is the one that keeps both private, and it's where this node genuinely shines. Keep that in mind, because a fresh pack with zero track record hasn't earned blind trust - read its source before you wire a real key into it.

CategoryAI 提示词

Inputs (12)

NameTypeDefaultDescription
providerCOMBOOpenAI Responses4 options: OpenAI Responses, OpenAI Chat, Anthropic Messages, LM Studio Compatible
urlSTRINGhttps://api.openai.com/v1
api_keySTRING
modelSTRINGgpt-4o-mini
system_templateSTRINGYou are a precise image prompt assistant.
questionSTRINGDescribe the image as a concise generation prompt.
resultSTRING
encode_clipBOOLEANfalse开启后,会使用连接到 clip 输入端的 CLIP 模型,把最终 result 文本编码为 CONDITIONING,并从 conditioning 输出端提供给 KSampler 的 positive 或 negative。若未连接 CLIP,开启后运行会报错。关闭时仍会正常输出 response 文本,但 conditioning 不会包含可用条件。
direct_modeBOOLEANfalse开启后,每次运行 ComfyUI 工作流都会重新请求语言模型,并用新响应继续执行,即使 result 已有内容。关闭时优先复用可编辑的 result;只有 result 为空时才请求模型。需要先审查或手动修改提示词时建议关闭。
imagesSTRING[]
imageoptIMAGE
clipoptCLIP

Outputs (2)

NameTypeDescription
responseSTRING
conditioningCONDITIONING