OpenAI Compatible LLM
Let an LLM answer inside your ComfyUI graph — text or vision, any OpenAI-compatible server
- image
- mcp_tools
- text
- reasoning_text
- raw_json
- usage_json
- unload_json
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 ishttp://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) andtemperature(0–2) - the knobs you'd expect.seed+seed_control- defaultrandommeans a fresh seed every run, so an LLM won't give you the same answer twice. Pickfixedwhen you actually want reproducibility;increment/decrementwalk 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.
Inputs (25)
| Name | Type | Default | Description |
|---|---|---|---|
| api_base_url | STRING | https://api.openai.com/v1 | Base 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_env | STRING | OPENAI_API_KEY | Environment variable that contains the Bearer API key/token. Leave empty for local servers that do not require authentication. |
| model | STRING | gpt-4o-mini | Model ID to send to the API server. Use the exact name expected by OpenAI, LM Studio, Ollama, or your compatible server. |
| system_prompt | STRING | You are a helpful assistant. | High-level behavior instruction sent as the system message. Leave empty to omit the system message. |
| user_prompt | STRING | Describe 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. |
| temperature | FLOAT | 0.700–2 | Controls randomness. Lower values are more deterministic; higher values are more varied. Usually adjust this or top_p, not both. |
| top_p | FLOAT | 1.000–1 | Nucleus sampling cutoff. 1.0 disables the cutoff. Usually leave at 1.0 when tuning temperature. |
| max_tokens | INT | 102464–262144 | Maximum number of tokens to generate. Some reasoning-capable servers may count hidden reasoning tokens against this budget. |
| max_tokens_field | COMBO | max_tokens | Which token-limit field to send for Chat Completions. Responses API URLs use max_output_tokens automatically; extra_body_json can override provider-specific details. |
| thinking | COMBO | default | Reasoning/thinking preference. Choose default to send no control, or choose off/on/an effort level and leave thinking_api_style on auto. |
| thinking_api_style | COMBO | auto | Advanced 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. |
| imageopt | IMAGE | Optional ComfyUI IMAGE input. Images are encoded as PNG data URLs and attached to the user message. | |
| mcp_toolsopt | MCP_TOOLS | Optional 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_detailopt | COMBO | auto | Vision 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_countopt | INT | 41–16 | Maximum number of images to send from a ComfyUI image batch. The default sends up to 4; lower it to reduce request size. |
| seedopt | INT | -1-1–2147483647 | Optional sampling seed. -1 omits the seed. Determinism is best-effort and depends on the provider/model. |
| presence_penaltyopt | FLOAT | 0.00-2–2 | Penalizes tokens that have already appeared, encouraging new topics. 0.0 is neutral and recommended by default. |
| frequency_penaltyopt | FLOAT | 0.00-2–2 | Penalizes repeated tokens based on how often they appear. Raise slightly if the model repeats phrases. 0.0 is neutral. |
| stopopt | STRING | Optional stop sequences. Generation stops before any listed string is returned. Use newline-separated strings or a JSON array of strings. | |
| json_modeopt | COMBO | off | Ask 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_jsonopt | STRING | Advanced escape hatch. A JSON object merged into the request body after normal fields, so it can add or override provider-specific parameters. | |
| extra_headers_jsonopt | STRING | Advanced escape hatch. A JSON object merged into HTTP headers after the default Content-Type, Accept, User-Agent, and Authorization headers. | |
| unload_after_callopt | COMBO | off | If on, attempts to unload the model after the LLM response. Useful for freeing VRAM before downstream image generation. |
| unload_provideropt | COMBO | auto | Provider used for model unload. auto detects common LM Studio/Ollama ports; choose explicitly when using a custom host, port, or reverse proxy. |
| timeout_secopt | INT | 1201–3600 | HTTP timeout in seconds for the main request and optional unload calls. Increase if model loading or long responses time out. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| text | STRING | The assistant's main text response extracted from the first choice. |
| reasoning_text | STRING | Reasoning/thinking text if the provider returns it separately; otherwise empty. |
| raw_json | STRING | The full JSON response from the selected endpoint: Chat Completions or Responses. |
| usage_json | STRING | The usage object from the response, such as token counts, when provided. |
| unload_json | STRING | Provider-specific unload result or warning. Empty JSON when unload_after_call is off. |