OpenAI API - Client
Every OpenAI API workflow in this pack starts here
- API Client
The whole comfyui-openai-api pack hinges on this one node. OAIAPI_Client doesn't generate anything itself - the name is half a lie, it never calls an API and needs no key if you don't want it to - but nothing else in the pack runs until you've wired it. It's the config node: it holds your endpoint, your key, and your request timeouts, and hands a ready-to-use client to the node that actually does the work.
What it actually is
Under the hood it builds an OpenAI object from the official openai Python package. That's it. You tell it where to connect and with what credentials, it constructs the client, and the output flows into OAIAPI_ChatCompletion's client input.
The important part is that "OpenAI API" is a protocol, not a company. The default base_url points at https://api.openai.com/v1, but you can repoint it at anything that speaks the OpenAI-compatible chat completions API - Ollama (http://localhost:11434/v1), vLLM, TGI, LM Studio, a hosted provider like Groq or OpenRouter. This is the single biggest reason to reach for this pack over something heavier: one client node, and suddenly any LLM or vision model you can serve is callable from inside your ComfyUI graph.
The inputs that matter
- base_url - the endpoint. Defaults to OpenAI's cloud API. For a local server, this is the one field you must change.
- api_key - here's the gotcha that trips everyone up. If you're talking to Ollama or another local server, leave the default
-in there. The author's own tooltip warns that an empty string key can trigger a connection error in the openai package - the dash placeholder isn't decorative, it's what keeps keyless local servers working. Only put a real key here for paid cloud endpoints. - max_retries (default 2) and timeout (default 600 seconds) - fine as shipped. That 10-minute timeout looks absurd until you're running a small model on CPU through Ollama and it's thinking hard.
What comes out
A single API Client output of type OAIAPI_CLIENT. It's an opaque custom type - you don't stringify it or display it, you just feed it into the Chat Completion node's client socket. One client per workflow is all you need; you can feed the same client to several chat nodes.
Installing it
This pack ships with Manager - search "OpenAI API" in the Custom Nodes Manager and hit install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/hekmon/comfyui-openai-api
Then restart ComfyUI. The nice part: there's nothing heavy to download. The only real new Python dependency is openai (numpy and Pillow are already part of ComfyUI), and there are zero model files - the models live on the server you point base_url at. One caveat: v2 of this pack is built on ComfyUI's newer native extension API, so it wants a reasonably recent ComfyUI. If the nodes don't appear after install, update ComfyUI first and try again.
Where people get burned
The classic failure is pasting a local URL in and getting a connection error - check that Ollama is actually running and that you used http, not https for localhost. The second classic is clearing api_key to blank instead of leaving the dash, which makes the openai client do weird things. And if you set a key for a local server that doesn't want one, it usually works anyway - but leaving - is the intended path. This is the most-installed node in the pack for a reason: it's the 30-second setup that makes "LLM in ComfyUI" real.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| base_url | STRING | https://api.openai.com/v1 | The base URL to use for the OpenAI API requests |
| max_retries | INT | 2 | Max number of retries for failed requests |
| timeout | INT | 600 | Request timeout in seconds |
| api_keyopt | STRING | - | The API key to use. An empty API key set with the openai package might end up with a connection error, leave the '-' placeholder if no key is needed. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| API Client | OAIAPI_CLIENT | The initialized and ready to query OpenAI API client |