OpenAI API - Client
The Node That Doesn't Need an OpenAI Account
- API Client
What it is
The name is a lie. This node does not talk to OpenAI, doesn't require an OpenAI account, and doesn't care whether you have a key. It builds an OpenAI-compatible API client - base URL, key, timeout, retries - and hands it to the rest of the pack over one wire. Point it at https://api.openai.com/v1 and you're paying OpenAI. Point it at http://localhost:11434/v1 and you're talking to Ollama on your own card, for free, forever.
That's why this node is the first thing you drop on the canvas. Everything else in the pack takes a client input, and every request runs through the object this node builds. One client, many completions.
Where it sits in the ecosystem: this is the bring-your-own-key path, not the official ComfyUI Partner Nodes. Partner Nodes are Comfy Org's vetted, prepaid-credit storefront for closed models. This is a small third-party pack that holds your key in a widget and calls whatever endpoint you name. That flexibility is the whole point - local models, vLLM, LM Studio, OpenRouter, a reseller proxy - and it also means the key on that widget is yours to protect. Note that ComfyUI's own API is unauthenticated by default; don't expose either one to the internet.
How it works
Under the hood it's just OpenAI(api_key=..., base_url=..., max_retries=..., timeout=...) from the official Python SDK. The base_url is validated when you queue the workflow - the scheme has to be http or https, so a bare localhost:11434/v1 gets rejected and http://localhost:11434/v1 passes. That validation runs whether the URL is typed into the widget or comes in from another node.
max_retries and timeout are passed straight to the SDK, and they're the two settings that decide whether a slow local model works or falls over. Retries cover a flaky connection; the timeout is the ceiling on a single request.
Inputs and outputs
- Base URL (
base_url) - defaulthttps://api.openai.com/v1. Your endpoint's/v1(or whatever version path it serves). - Max Retries (
max_retries) - default 2, minimum 0. - Timeout (
timeout) - default 600 seconds, minimum 1. A local 8B model writing 800 tokens can genuinely take minutes; the default is generous on purpose, so raise it rather than fight it. - API Key (
api_key) - optional, default-. Leave the dash if your server doesn't check keys.
One output: API Client (OAIAPI_CLIENT), which plugs into the client input of Chat Completion and Batched Chat Completion.
Install
ComfyUI Manager → search OpenAI API or Comfpod, or:
cd ComfyUI/custom_nodes
git clone https://github.com/lany42/comfyui-openai-api
cd comfyui-openai-api
/path/to/ComfyUI/.venv/bin/python -m pip install -r requirements.txt
# restart ComfyUI
The only real dependency is the openai Python SDK (>=2.7.1,<3) plus numpy and Pillow. Nothing downloads model weights. This pack is a fork of hekmon's comfyui-openai-api; if you have both installed you'll see two identically-named OpenAI API - Client nodes in the menu, so pick one and stay with it.
Where people get burned
Empty key, connection error. The author's own tooltip flags it: clearing the key field rather than leaving - can end up as a connection error from the SDK, which reads like a network problem and isn't. If you truly need no key, keep the placeholder.
Missing scheme. localhost:11434/v1 won't validate. Add http://.
Docker. If ComfyUI runs in a container, localhost is the container, not your host. Ollama on the host machine is at http://host.docker.internal:11434/v1 (or the host's LAN IP), and Ollama itself needs to be listening on all interfaces, not just loopback.
Wrong path. Ollama wants the /v1 suffix; some proxies expect /v1/ with a trailing slash; LM Studio's server is http://localhost:1234/v1. A 404 on every request is almost always the path, not the model name.
Timeout on long generations. If you point this at a slow local model and get "request timed out", raise Timeout before you start debugging the model.
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 |