Nodes/OpenAI Compatible LLM/OpenAI Compatible LLM
ComfyUI Node

OpenAI Compatible LLM

Let an LLM answer inside your ComfyUI graph — text or vision, any OpenAI-compatible server

By godmt·Created 2 months ago·Updated 6 days ago· 6
OpenAI Compatible LLM
  • image
  • mcp_tools
  • text
  • reasoning_text
  • raw_json
  • usage_json
  • unload_json
api_base_urlhttps://api.openai.com/v1
api_key_envOPENAI_API_KEY
modelgpt-4o-mini
system_promptYou are a helpful assistant.
user_promptDescribe the provided image in detail, focusing on visible subjects, composition, colors, lighting, style, and mood.
temperature0.70
top_p1.00
max_tokens1024
max_tokens_fieldmax_tokens
thinkingdefault
thinking_api_styleauto
image_detailauto
image_max_count4
seed-1
presence_penalty0.00
frequency_penalty0.00
stop
json_modeoff
extra_body_json
extra_headers_json
unload_after_calloff
unload_providerauto
timeout_sec120

ComfyUI is genuinely great at making images and famously dumb at words. OpenAICompatibleLLM is the bridge: a single node that lets any OpenAI-compatible chat server - Ollama, LM Studio, vLLM, LocalAI, or OpenAI itself - answer inside your graph. Hook the reply into your prompt, and you've turned the workflow into something that can rephrase a prompt until the model likes it, describe a reference image into a caption, or just explain a broken output in plain text. It's a pattern people have been bolting together by hand for a while - building the same wrapper for personal use is practically a rite of passage on r/comfyui - and this is the packaged version.

The name is a small lie in the best way: this node calls no API of its own and needs no key. The whole thing is a ~200-line requests wrapper. You point it at an endpoint, it posts a standard OpenAI Chat Completions payload, and hands the reply back as a string. Nothing to download, no model files, no GPU to babysit. If you can run the LLM elsewhere, this node can reach it.

How it works. generate() does one POST to whatever endpoint you give it, with model, messages, max_tokens, temperature, and a seed in the body. If you feed an image in, it takes the first frame of the batch tensor, base64-encodes it as PNG, and drops it into the message as an image_url part with a detail level. That's the whole vision story - "a chat completion with a picture attached." It also means the model you point at has to actually be a vision model (Qwen-VL, LLaVA, GPT-4o, that family); a text-only model will just complain or hallucinate.

The inputs that actually matter:

  • endpoint - the full path, including /v1/chat/completions. Default is http://localhost:3010/v1/chat/completions, which is nobody's real default: Ollama listens on 11434, vLLM on 8000. You will change this, and the first thing to check when nothing works is that you did.
  • model - the model name exactly as your server knows it.
  • prompt - multiline; this is your actual message to the LLM.
  • max_tokens (1–32000, default 2000) and temperature (0–2) - the knobs you'd expect.
  • seed + seed_control - default random means a fresh seed every run, so an LLM won't give you the same answer twice. Pick fixed when you actually want reproducibility; increment/decrement walk from the last seed.

Optional extras: api_key (adds a Bearer header - blank for local servers), image_detail (auto/low/high, mostly a token-cost trade), and enable_thinking, which tacks chat_template_kwargs: {"enable_thinking": true} onto the request for reasoning models like QwQ or DeepSeek-R1 served via vLLM. Skip it unless your server/model support it.

Output: a single STRING named response. Feed it into Show Text to read it, or into any prompt/string input - using this node as an automatic prompt writer for your KSampler is the classic move. One nice touch: errors don't crash the graph, they get returned as text in that same output, so a failed call is readable rather than a red wall.

Installing. Grab it via ComfyUI Manager (search "OpenAI Compatible"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/yeeyou/ComfyUI-OpenAI-Compatible-API

then restart. Dependencies are requests, pillow, torch, numpy - every one of which ComfyUI already ships, so there's no heavy install and no model download. Heads-up: the README's own clone command says git clone https://github.com/your-repo/... - a literal placeholder, the classic copy-paste trap. Use the URL above.

Where people get burned. Connection failures are almost always endpoint/port/path, not the node. Vision fails when the model isn't vision-capable. And remember this node ships your prompt and your image to whatever endpoint you type - the ecosystem has a real horror story in the ComfyUI_LLMVISION malware incident, so point it at a local Ollama/vLLM/LM Studio instance you control, not some random remote service. It's a small, new, MIT-licensed community node, so expect a light feature set - but for a two-minute text-in-text-out bridge, it does exactly one job and does it fine.

CategoryLLM/OpenAI Compatible

Inputs (25)

NameTypeDefaultDescription
api_base_urlSTRINGhttps://api.openai.com/v1Base URL or full endpoint. Use /v1 for the default Chat Completions endpoint. Use /v1/chat/completions to force Chat Completions. Use /v1/responses to try the newer Responses API; if that endpoint is not supported, this node falls back to the sibling /chat/completions endpoint.
api_key_envSTRINGOPENAI_API_KEYEnvironment variable that contains the Bearer API key/token. Leave empty for local servers that do not require authentication.
modelSTRINGgpt-4o-miniModel ID to send to the API server. Use the exact name expected by OpenAI, LM Studio, Ollama, or your compatible server.
system_promptSTRINGYou are a helpful assistant.High-level behavior instruction sent as the system message. Leave empty to omit the system message.
user_promptSTRINGDescribe the provided image in detail, focusing on visible subjects, composition, colors, lighting, style, and mood.Main user request sent as the user message. When an IMAGE is connected, this text is sent together with the image.
temperatureFLOAT0.700–2Controls randomness. Lower values are more deterministic; higher values are more varied. Usually adjust this or top_p, not both.
top_pFLOAT1.000–1Nucleus sampling cutoff. 1.0 disables the cutoff. Usually leave at 1.0 when tuning temperature.
max_tokensINT102464–262144Maximum number of tokens to generate. Some reasoning-capable servers may count hidden reasoning tokens against this budget.
max_tokens_fieldCOMBOmax_tokensWhich token-limit field to send for Chat Completions. Responses API URLs use max_output_tokens automatically; extra_body_json can override provider-specific details.
thinkingCOMBOdefaultReasoning/thinking preference. Choose default to send no control, or choose off/on/an effort level and leave thinking_api_style on auto.
thinking_api_styleCOMBOautoAdvanced override. Leave on auto: Chat Completions uses reasoning_effort, Responses uses reasoning.effort, and recognized cloud URLs are adjusted automatically. The old none value also behaves as auto so saved workflows honor thinking. Choose another value only for a server that needs a nonstandard request field.
imageoptIMAGEOptional ComfyUI IMAGE input. Images are encoded as PNG data URLs and attached to the user message.
mcp_toolsoptMCP_TOOLSOptional Remote MCP tools list. Only used with Responses API URLs such as /v1/responses. Connect MCP Tools Stack or a preset MCP tool node.
image_detailoptCOMBOautoVision detail hint for image understanding. auto/low/high/original follow OpenAI-style image input options; omit sends no detail field for stricter local servers.
image_max_countoptINT41–16Maximum number of images to send from a ComfyUI image batch. The default sends up to 4; lower it to reduce request size.
seedoptINT-1-1–2147483647Optional sampling seed. -1 omits the seed. Determinism is best-effort and depends on the provider/model.
presence_penaltyoptFLOAT0.00-2–2Penalizes tokens that have already appeared, encouraging new topics. 0.0 is neutral and recommended by default.
frequency_penaltyoptFLOAT0.00-2–2Penalizes repeated tokens based on how often they appear. Raise slightly if the model repeats phrases. 0.0 is neutral.
stopoptSTRINGOptional stop sequences. Generation stops before any listed string is returned. Use newline-separated strings or a JSON array of strings.
json_modeoptCOMBOoffAsk the API for JSON-object output. Chat Completions sends response_format; Responses sends text.format. The prompt should still explicitly ask for JSON.
extra_body_jsonoptSTRINGAdvanced escape hatch. A JSON object merged into the request body after normal fields, so it can add or override provider-specific parameters.
extra_headers_jsonoptSTRINGAdvanced escape hatch. A JSON object merged into HTTP headers after the default Content-Type, Accept, User-Agent, and Authorization headers.
unload_after_calloptCOMBOoffIf on, attempts to unload the model after the LLM response. Useful for freeing VRAM before downstream image generation.
unload_provideroptCOMBOautoProvider used for model unload. auto detects common LM Studio/Ollama ports; choose explicitly when using a custom host, port, or reverse proxy.
timeout_secoptINT1201–3600HTTP timeout in seconds for the main request and optional unload calls. Increase if model loading or long responses time out.

Outputs (5)

NameTypeDescription
textSTRINGThe assistant's main text response extracted from the first choice.
reasoning_textSTRINGReasoning/thinking text if the provider returns it separately; otherwise empty.
raw_jsonSTRINGThe full JSON response from the selected endpoint: Chat Completions or Responses.
usage_jsonSTRINGThe usage object from the response, such as token counts, when provided.
unload_jsonSTRINGProvider-specific unload result or warning. Empty JSON when unload_after_call is off.