Nodes/ComfyUI-Alchemine-Pack/OpenAI Inference
ComfyUI Node

OpenAI Inference

One node for every OpenAI-compatible LLM backend, with vision and thinking mode

By alchemine·Created about a year ago·Updated 2 days ago· 2
OpenAI Inference
  • image
  • response
  • reasoning
promptHello, world!
system_instructionYou are a helpful assistant.
base_url
api_key
model
max_output_tokens100
seed0
temperature0.7
thinkfalse

OpenAIInference is a single node that talks to any OpenAI-compatible API - OpenAI proper, vLLM, Ollama's /v1 endpoint, Gemini's OpenAI-compatible endpoint, whatever. Point base_url, api_key, and model at the server you want, give it a prompt, and it returns the answer as a STRING you can wire into anything. It also does vision (feed it an IMAGE) and thinking mode (get the reasoning trace back separately).

If you've been doing tag-optimization or prompt-rewriting workflows with hardcoded scripts, this is the node that makes it a first-class part of the graph. Toss a prompt in from a prior node, get a refined prompt out, feed it to your sampler. That's the whole game for a lot of this pack's audience.

How it works

It's a thin, careful wrapper around the Chat Completions API. The prompt and system instruction go in as messages; temperature and seed are passed through; max_output_tokens caps the reply. If you feed it an image, it encodes the tensor to PNG, base64s it, and attaches it as an image_url content part in the standard vision format - no separate vision endpoint to configure.

Two details make it friendlier than a raw API call:

  • Auto model detection. Leave model empty and it hits /models on your backend and picks the model - if exactly one is available. Nice for local Ollama setups where you've got one model loaded.
  • Thinking mode. With think on, it requests the reasoning trace. Some backends (vLLM, DeepSeek-style) return it as a reasoning_content field; others inline it as <think>...</think>. Either way the node splits it out so response is the clean answer and reasoning is the trace - empty if there was none.

Credentials follow the pack's pattern: node inputs first, falling back to OPENAI_BASE_URL / OPENAI_API_KEY env vars. There's also a cache so identical calls don't re-bill you.

Outputs are response (the answer) and reasoning (the thinking trace). Both STRING.

Inputs that matter

  • prompt - what you're asking. Multiline.
  • base_url / api_key / model - set all three unless you're leaning on env vars. base_url for OpenAI is https://api.openai.com/v1.
  • max_output_tokens (default 100) - the one beginners consistently under-set. Tag-rewriting replies are short, but a full prompt restructure can blow past 100 tokens.
  • think - flip on for reasoning models.

Install

Part of ComfyUI-Alchemine-Pack:

cd ComfyUI/custom_nodes
git clone https://github.com/alchemine/comfyui-alchemine-pack
pip install -r requirements.txt

Or via ComfyUI Manager (search "ComfyUI-Alchemine-Pack"). The pack's only dependency is python-dotenv; this node needs no local models at all, just a reachable API.

Common issues

Empty model with a backend that exposes several models fails the auto-detect - it needs exactly one to pick for you; otherwise type the model name. max_output_tokens at the default 100 truncates long generations silently. And if you're using a .env file, remember ComfyUI needs a restart for env changes to take effect - the "it worked yesterday" ghost is almost always a stale env.

CategoryAlcheminePack/Inference

Inputs (10)

NameTypeDefaultDescription
promptSTRINGHello, world!
system_instructionSTRINGYou are a helpful assistant.
base_urlSTRING
api_keySTRING
modelSTRING
max_output_tokensINT1001–131072
seedINT0
temperatureFLOAT0.70–2
thinkBOOLEANfalse
imageoptIMAGE

Outputs (2)

NameTypeDescription
responseSTRING
reasoningSTRING