Create OpenAI Client
The key-and-transport hub for gpt-image in ComfyUI
- client
Create OpenAI Client is the credentials-and-transport factory that powers the pack's paid-image nodes (OpenAI Image Edit and OpenAI Image Generation). It doesn't generate anything itself - it assembles an OPENAI_CLIENT object carrying your API key, endpoint, timeout, and the low-level decisions about how images get uploaded, then hands that object to the nodes that actually call the API. It's the config hub, and getting it right is the difference between working gpt-image calls and an afternoon of confusing 400s.
The reason this node exists as a separate step is that OpenAI's image endpoints have genuinely fiddly transport requirements. gpt-image uploads can go as JSON-encoded base64 or as multipart/form-data; some OpenAI-compatible proxies accept one and reject the other; and the multipart field name for the image is not standardized (image[] vs image). This node surfaces all of that as explicit choices instead of hardcoding it, which is exactly what a pack author who fought a third-party proxy would build.
The inputs
- api_key - your key.
- base_url - defaults to
https://api.openai.com/v1. Point it at any OpenAI-compatible gateway. - timeout - request timeout in seconds (default 300). Image API calls are slow; don't set it too low.
- image_upload_mode -
multipart_form(default) orjson_base64. Flip this when a proxy rejects your requests. - multipart_image_field -
image[](default) orimage. Only relevant in multipart mode; another proxy-compat switch. - transport -
requests(default) orcurl.curlshells out to a real curl binary - a fallback for environments where Python's HTTP stack is being blocked or proxied weirdly.curl_pathlets you point at the binary (defaultcurl).
One output: client, an OPENAI_CLIENT, which wires into OpenAI Image Edit or OpenAI Image Generation.
Install
The pack standard:
cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack
cd duanyll_nodepack && pip install -r requirements.txt
or ComfyUI Manager → "Duanyll Nodepack" → install → restart. The node itself needs only requests; the pack's other requirements (OpenCV, kornia, insightface, matplotlib, Volcengine SDK) install alongside.
Gotchas
The same secret-in-workflow warning as the S3 client: the API key is plain text in your workflow JSON, so don't share the file. And the transport options exist for a reason - if you're behind a corporate proxy or using a non-OpenAI gateway, the defaults may simply not work, and the fix is usually flipping image_upload_mode or switching to curl before you blame the API. This is the most "pack author learned the hard way" node in the bunch, and for anyone actually running gpt-image workflows, those hard-won switches are the value. It's not glamorous, but it's the difference between a working pipeline and a dead one.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | — | |
| base_url | STRING | https://api.openai.com/v1 | — |
| timeout | INT | 3001–3600 | — |
| image_upload_mode | COMBO | multipart_form | 2 options: json_base64, multipart_form |
| multipart_image_field | COMBO | image[] | 2 options: image[], image |
| transport | COMBO | requests | 2 options: requests, curl |
| curl_path | STRING | curl | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| client | OPENAI_CLIENT | — |