Nodes/ComfyUI FlexAI Nodes/OpenAI Text (FlexAI)
ComfyUI Node

OpenAI Text (FlexAI)

Chat with your images, and let an LLM talk back to your graph

By Semonxue·Created 12 months ago·Updated 9 months ago· 6
OpenAI Text (FlexAI)
  • image_1
  • image_2
  • image_3
  • image_4
  • STRING
providerdefault
modelgpt-4o
custom_model
temperature0.5
system_promptYou are a helpful assistant.
user_promptDescribe the following images.
seed0
top_p1.00
include_usagetrue
streamtrue
debugfalse

Most ComfyUI nodes convert one tensor into another. This one converts your question - and optionally up to four images - into a remote LLM's answer, returned as a plain STRING. It's the sibling node to the pack's image generator, and the two are clearly designed to work together: the image node makes pictures, this one talks about them.

Why would you want that in a diffusion tool? Because ComfyUI is a graph that takes strings in and puts strings out everywhere - prompts, captions, metadata. With this node wired into the graph you can auto-caption a batch of renders, have a model describe what it sees so a text-to-image model can re-prompt it, or turn a rough idea into a finished prompt without ever leaving the editor. It's the kind of automation that a form-based UI never lets you build, and honestly the graph makes it feel natural.

How it works

The node builds a standard /v1/chat/completions request with your system_prompt and user_prompt, plus any attached images. Reference images are converted to JPEG data URLs and auto-scaled so the longest side never exceeds 1024px - keeps token cost down, at the cost of some fine detail. Streaming is on by default (with usage tracking), and the code aggregates the stream and hands you just the final text.

One thing worth knowing before you fall in love: max_tokens is hardcoded at 4096. There's no input for it, and no way to raise it. Fine for captions and prompts; a real ceiling if you're asking for long-form output.

The inputs that matter

  • provider - pick which API channel from your .env to talk through. Set up several and switch on the fly.
  • model / custom_model - the dropdown holds saved models; type anything into custom_model to call it once and have it remembered for next time.
  • system_prompt - the persona/instructions. Defaults to "You are a helpful assistant."
  • user_prompt - the actual ask, multiline. Defaults to "Describe the following images.", which is exactly what you want for the vision use case.
  • temperature - 0 to 2, default 0.5. Lower for deterministic captions, higher for creative re-prompts.
  • image_1 … image_4 - the optional reference images. None attached? You get plain text chat. Attach one and it's vision mode; attach several and it's a hybrid analysis.

The optional seed, top_p, stream, include_usage, and debug toggles round it out. Note seed only does anything if it's greater than 0 - a seed of 0 means "no seed", which trips people up constantly.

The output is a single STRING containing the model's reply. Wire it into a text display node, a ShowText-style logger, or a prompt-prep/CLIP text encode step if you want the LLM to write the next image's prompt.

Installing it

Same pack as the image node, same steps:

# ComfyUI Manager: search "ComfyUI FlexAI" and install
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Semonxue/Comfyui-flexai.git
cd Comfyui-flexai
pip install -r requirements.txt

Dependencies are just openai, Pillow, python-dotenv, and requests - no heavy downloads. Then drop a .env in the plugin folder with OPENAI_API_KEY=... (plus an optional OPENAI_API_BASE) or the multi-provider OPENAI_API_KEY_<name> form, and restart ComfyUI.

Troubleshooting

  • "API key is not configured" - the .env.example ships placeholder sk_... keys that the node rejects on purpose. Fill in real ones, restart, and make sure the file is named .env in the plugin root.
  • Provider dropdown doesn't show your new provider - the provider list is read at node load. Restart ComfyUI after editing .env; the dropdown refreshes with it.
  • Answer feels cut off - that's the 4096-token cap. Break the task into pieces instead of hunting for a setting that doesn't exist.
  • Vision results are oddly low-detail - your images got resized to 1024px and JPEG'd. That's intentional; feed a tighter crop if fine detail matters.
  • "API returned an empty response" - a genuinely empty reply. Usually a provider/model mismatch, and the debug toggle will show you the exact request in debug.log.

And the evergreen caveat: this node uploads whatever you attach to a third-party server. It's a great tool, but treat it like a stranger's upload box - don't attach anything you wouldn't email to the API provider, and remember every custom node runs its code with your permissions.

Categoryflexai

Inputs (15)

NameTypeDefaultDescription
providerCOMBOdefault1 options: default
modelCOMBOgpt-4o3 options: gpt-4o, gpt-4-turbo, gpt-3.5-turbo
custom_modelSTRING
temperatureFLOAT0.50–2
system_promptSTRINGYou are a helpful assistant.
user_promptSTRINGDescribe the following images.
image_1optIMAGE
image_2optIMAGE
image_3optIMAGE
image_4optIMAGE
seedoptINT00–2147483647
top_poptFLOAT1.000–1
include_usageoptBOOLEANtrue
streamoptBOOLEANtrue
debugoptBOOLEANfalse

Outputs (1)

NameTypeDescription
STRINGSTRING