Nodes/ComfyUI_Lam/OpenAi工具
ComfyUI Node

OpenAi工具

An OpenAI-compatible chat node that defaults to Aliyun

By yanlang0123·Created 2 years ago·Updated about a month ago· 76
OpenAi工具
  • messages
  • images
  • 结果
  • messages
server_urlhttps://dashscope.aliyuncs.com/compatible-mode/v1
api_key
model_nameqwen3-max-preview
system_prompt
text

OpenAiPrompt ("OpenAi工具") is a chat-in-the-graph node that talks to any OpenAI-compatible API. You send it a prompt, optionally an image, and it returns the model's reply plus the running message history. The name is a bit of a lie, in the best way: it doesn't care whether you're talking to OpenAI at all. The default endpoint is Aliyun's DashScope compatible-mode URL, the default model is qwen3-max-preview, and it'll happily talk to a local vLLM server or anything else that speaks the OpenAI protocol. It's a bring-your-own-API-key LLM call you can drop mid-workflow.

Why put a chat call in a generation graph? Prompt work. Generate a prompt from a spec, translate and restyle one, ask a vision model what's in a reference image and feed the answer into your conditioning. Because it keeps a messages list output, you can loop a conversation - send the history back in and the node continues the thread instead of starting fresh. That's what separates this from a one-shot "prompt enhancer": it's a stateful client.

How it works

Standard OpenAI client under the hood. It builds a message list (system prompt first if provided), appends your text as a user message, and calls chat.completions.create. Two things make it interesting:

  • Vision: if you wire an images input, it base64-encodes the image (from a tensor or a file path) and sends it as an image_url content part. So it's a VLM node - "describe this character," "extract the text on this sign," and the answer comes back as a string you can route into your workflow.
  • State: the messages output carries the full conversation, and feeding it back into the messages input continues the thread. Each call appends both your message and the assistant's reply.

The inputs and outputs

  • server_url - any OpenAI-compatible base URL. Default is DashScope's compatible endpoint.
  • api_key - your key. Empty default; you must supply it.
  • model_name - e.g. qwen3-max-preview, gpt-4o, whatever your endpoint serves.
  • system_prompt, text - the system framing and your user message.
  • Optional: messages (conversation history), images (IMAGE or a file path string).
  • Outputs: 结果 (the assistant's reply, STRING) and messages (the updated history, LIST).

Installing it

From ComfyUI_Lam: Manager → "ComfyUI_Lam", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

Restart, lam category. It needs the openai Python package (in the pack's requirements - a normal, safe dependency) and an API key. None of the pack's model downloads are involved; this is a cloud call.

Common issues

The usual API-call failures: missing or wrong key (401), hitting an endpoint that doesn't serve the model you named, and rate limits. The node is thin on error handling - a failed call tends to fail the queue - so test with a trivial prompt before wiring it into something precious. Vision needs a model that actually accepts images; a text-only model with an image wired in will error or ignore it depending on the provider. And keep an eye on cost: a loop that re-sends history grows the token count every turn.

Pack caveats: Chinese-language UI, tiny community presence. And if you uninstall the pack, delete ComfyUI/web/extensions/lam to clear the leftover popup the frontend extension leaves behind.

Categorylam

Inputs (7)

NameTypeDefaultDescription
server_urlSTRINGhttps://dashscope.aliyuncs.com/compatible-mode/v1
api_keySTRING
model_nameSTRINGqwen3-max-preview
system_promptSTRING
textSTRING
messagesoptLIST
imagesoptIMAGE,STRING

Outputs (2)

NameTypeDescription
结果STRING
messagesLIST