Nodes/comfyui-FOK_API_tools/FOK Multi-Protocol Chat Vision API
ComfyUI Node

FOK Multi-Protocol Chat Vision API

Stick any chat API in your graph — text plus up to four images, without baking your key into the workflow

By facok·Created 2 months ago·Updated 2 months ago· 5
FOK Multi-Protocol Chat Vision API
  • image_1
  • image_2
  • image_3
  • image_4
  • response_text
  • debug_info
api_protocolopenai_chat_completions
modelgpt-4o
prompt
api_base_urlhttps://api.openai.com/v1
on_errorskip
timeout120
system_prompt
max_tokens2048
temperature0.70
api_key_fileapi_key.txt
anthropic_version2023-06-01

FOK Multi-Protocol Chat Vision API is one node that talks to basically every chat API you'd want from inside ComfyUI: OpenAI's Chat Completions, OpenAI's newer Responses format, Anthropic Messages, and Gemini GenerateContent - or any local server that speaks one of those protocols. Send it a prompt plus up to four images, it returns the model's reply as a plain string you can wire into the rest of your workflow. If you've been running LLM prompt-rewriting or VLM captioning locally and want to swap in a frontier model for the same job, this is the API path of the local-vs-API decision, done properly.

What it actually does

The node builds the request body for whichever protocol you pick, POSTs it to your endpoint, and parses just the text back out. Pick api_protocol, it appends the right path to your base URL: /chat/completions, /responses, /messages, or /models/{model}:generateContent for Gemini. Your IMAGE tensors get encoded to base64 PNG and stuffed into the provider's image format (image_url for OpenAI, base64 blocks for Anthropic, inline data for Gemini), so anything you can preview in ComfyUI can go straight to the model - a frame you're about to animate, a reference you want described, the image you're about to img2img.

What makes it worth a look beyond the usual "send text to an API" node is the protocol coverage. Those formats aren't just for the big three. Ollama, vLLM, LM Studio, and a pile of proxies all expose OpenAI-compatible endpoints, so you can point this at a local server and get the same node in both your free tier and your paid tier. The model field is passed through unchanged, so aliases work - put whatever your service calls the model.

The inputs that actually matter

  • api_protocol - the wire format. If you're unsure, OpenAI-compatible (openai_chat_completions) is what most self-hosted servers speak.
  • api_base_url - your endpoint. Defaults to https://api.openai.com/v1; the node appends the protocol path.
  • prompt - the user text (force-connected, so drop a text node in).
  • on_error - failure behavior, and the trap, see below.

Beyond those: system_prompt (mapped to system / instructions / systemInstruction per protocol), image_1 through image_4, max_tokens, temperature, timeout, and anthropic_version (that header is only sent for the Anthropic protocol; leave it at the default). One thing to notice: the default model is gpt-4o, but that's just a starting point - the node won't validate it against anything.

Outputs

Two strings: response_text is the model's answer, ready for a text display, a Save node, or another LLM step. debug_info is a JSON blob of the request URL, headers, payload, and response - auth headers redacted, big base64 payloads trimmed. Keep it attached to a text preview the first few runs; when a provider returns a confusing error, that debug output is where the answer lives.

Installing it

One node, no heavy dependencies - the pack only needs requests and Pillow, both of which ship with ComfyUI. No models to download. In ComfyUI Manager, search for "comfyui-FOK_API_tools", or:

cd ComfyUI/custom_nodes
git clone https://github.com/facok/comfyui-FOK_API_tools

Restart, and the node appears under FOK API Tools/API. The one extra setup step: create api_key.txt inside the node's folder (custom_nodes/comfyui-FOK_API_tools/) containing only your key - a api_key.txt.example ships as a template.

Where people get burned

The key file is the design, not an oversight. There is deliberately no key input box, because workflow JSON gets exported, shared, and pasted into bug reports - keys in workflows leak. The api_key_file input only accepts a bare filename in the node's own directory; absolute paths and ../ are rejected outright. That's a small annoyance if you juggle multiple services, but it's the right trade.

The real trap is on_error's default: skip. On a failed call it returns your original prompt unchanged, so a broken API key or wrong URL doesn't error the workflow - it silently passes your raw text downstream. If that text is feeding a captioner or prompt rewriter, you've just sent unprocessed input into your sampler and might not notice. Set on_error to stop (blocks downstream when ExecutionBlocker is available) or raise until you're confident the call works.

Also worth knowing: four images is the ceiling, not a suggestion - a fifth input isn't silently dropped because there isn't one. And with Gemini, remember the model name is baked into the URL path; either put {model} in api_base_url or a full URL ending in :generateContent. Given how small this pack is, there's not much room to go wrong - which is exactly why it's worth having for the days you'd rather pay per call than watch a local model fiddle.

CategoryFOK API Tools/API

Inputs (15)

NameTypeDefaultDescription
api_protocolCOMBOopenai_chat_completionsChoose the JSON protocol sent to the server. openai_chat_completions -> /chat/completions; openai_responses -> /responses; anthropic_messages -> /messages; gemini_generatecontent -> /models/{model}:generateContent. Select the format expected by your API service.
modelSTRINGgpt-4oModel name passed through unchanged, for example gpt-4o, claude-3-5-sonnet-latest, gemini-2.5-flash, or a model alias configured by your API service.
promptSTRINGUser prompt sent with the optional images. Connect a text node here.
api_base_urlSTRINGhttps://api.openai.com/v1Base URL for the API service. The node appends the endpoint for the selected protocol. Examples: https://api.openai.com/v1, https://api.anthropic.com/v1, or https://generativelanguage.googleapis.com/v1beta. For Gemini you may also provide a full URL ending in :generateContent or include {model}.
on_errorCOMBOskipFailure behavior. skip returns the original prompt; stop blocks downstream nodes when ExecutionBlocker is available; raise throws the error and stops execution.
timeoutINT12010–600HTTP request timeout in seconds. Increase for slow models or image-heavy requests.
system_promptoptSTRINGOptional system/instruction text. Mapped to system, instructions, or systemInstruction depending on the selected protocol.
image_1optIMAGEOptional first image. Sent as PNG base64.
image_2optIMAGEOptional second image. Sent as PNG base64.
image_3optIMAGEOptional third image. Sent as PNG base64.
image_4optIMAGEOptional fourth image. Sent as PNG base64.
max_tokensoptINT20481–32768Maximum text tokens to generate. Sent as max_tokens for Chat/Anthropic, max_output_tokens for Responses, and maxOutputTokens for Gemini.
temperatureoptFLOAT0.700–2Sampling temperature. Lower is more deterministic; higher is more varied.
api_key_fileoptSTRINGapi_key.txtFile name only, read from this node directory. Do not enter an API key here. Default: api_key.txt. This keeps secrets out of workflow JSON files. Absolute paths and ../ are rejected.
anthropic_versionoptSTRING2023-06-01Anthropic API version header used only for anthropic_messages. Leave default unless your API service requires another value.

Outputs (2)

NameTypeDescription
response_textSTRING
debug_infoSTRING