OpenAI API 加载器
One loader, every OpenAI-compatible API under the sun
- api_instance
Don't let the name fool you
OpenAIApiLoader is really an "OpenAI-compatible" loader. It drives the official openai Python SDK with a configurable base_url, which means it talks to OpenAI proper, ModelScope, DeepSeek, Qwen endpoints, Groq, Ollama, LM Studio, vLLM, SiliconFlow - anything that speaks the chat-completions protocol. That's why the defaults are telling: the model is deepseek-ai/DeepSeek-R1 and the base URL points at api-inference.modelscope.cn, a Chinese model-hosting platform, not at OpenAI. The author clearly built this for the Chinese market first and made it universal by accident of the SDK.
Like the Gemini loader, it doesn't make any network call on its own. It builds an OpenAI client (key, base URL, optional proxies, timeout) and hands you an OPENAI_API_INSTANCE for OpenAIChat, OpenAIFileUploader, and friends. No tokens spent until a Chat node actually runs.
The fields that matter
api_key-sk-xxxxis the placeholder. Whatever key your chosen provider expects.model- a free-text model id. Remember it's per provider: a model string that works on ModelScope won't exist on OpenAI proper.base_url- the chat-completions endpoint. Most providers want the/v1/suffix; the code appends one if you leave it off.proxy_http/proxy_https- same story as the Gemini loader: for GFW/corporate proxy users (the example is the classic Clash port,http://127.0.0.1:7890). Only set if needed.timeout- 120s default, up to 600. Tight for slow reasoning models; bump it.channel_group- named presets in the pack'sopenai.yaml, overriding the inline key/base_url.
The loader caches its client keyed on a hash of your config, so unchanged workflows reuse one connection, and changing the key or endpoint rebuilds cleanly. The pack also adds a small web panel to the loader that can fetch the live model list from whatever endpoint you're pointed at - genuinely handy when you're probing an unfamiliar provider.
Install
ComfyUI Manager (search "comfyui-aichat") or:
cd ComfyUI/custom_nodes
git clone https://github.com/spawner1145/comfyui-aichat
Restart ComfyUI. The requirements - openai, httpx, PyYAML - install automatically on first load. No model downloads; you only need an API key from whichever provider you choose. The UI strings lean Chinese (the pack's audience does), but the fields are self-explanatory.
Where people get burned
- The API key rides in the workflow JSON in plain text. Shared workflows leak it. Strip keys before sharing, and don't expose ComfyUI to the internet - the ecosystem's LLM-node malware incident is a real warning, not a hypothetical.
- Mismatched model/endpoint. The clearest failure mode: a DeepSeek model string against an OpenAI URL, or vice versa. Keep the model and base_url from the same provider.
- Providers without a
/modelsroute will make the model-fetch panel error - that's cosmetic; the node itself still works. - Timeouts on reasoning models: 120s is short for a long R1 chain-of-thought. When a call dies at the timeout boundary, raise it before you blame the workflow.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | sk-xxxx | — |
| model | STRING | deepseek-ai/DeepSeek-R1 | — |
| base_url | STRING | https://api-inference.modelscope.cn/v1/ | — |
| proxy_httpopt | STRING | — | |
| proxy_httpsopt | STRING | — | |
| timeoutopt | FLOAT | 12010–600 | — |
| channel_groupopt | STRING | — | |
| use_responsesopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| api_instance | OPENAI_API_INSTANCE | — |