BYOK OpenAI gpt-image generation and editing nodes for ComfyUI — calls go directly to the OpenAI API with your own key (no proxy, no credit markup). - Two nodes: "Imagent: OpenAI Image" (text-to-image) and "Imagent: OpenAI Image Edit" (edit / inpaint / multi-reference compose). - Models gpt-image-2 / gpt-image-1.5 / gpt-image-1 with a per-model dynamic UI (comfy_api DynamicCombo): size, background, custom WxH, and input_fidelity are revealed only for the models that support them. - Edit node accepts an auto-growing set of reference images (up to 16) plus an optional inpaint mask; generate supports batches up to 8. - API key via OPENAI_API_KEY or a local config.json. Requires ComfyUI >= 0.23.0.
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
"""ComfyUI-Imagent: OpenAI gpt-image generation and editing nodes.
|
|
|
|
The nodes use the comfy_api IO schema (DynamicCombo for per-model widgets), so we
|
|
register them via the V3 `comfy_entrypoint`/ComfyExtension path. Requires
|
|
ComfyUI >= 0.23.0 (for IO.DynamicCombo).
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
# ComfyUI loads this __init__.py via importlib.util.spec_from_file_location,
|
|
# which does NOT add the custom-node directory to sys.path. Add it so that
|
|
# `import imagent.*` resolves whether installed editable or bind-mounted.
|
|
_here = os.path.dirname(os.path.abspath(__file__))
|
|
if _here not in sys.path:
|
|
sys.path.insert(0, _here)
|
|
|
|
# The nodes use the comfy_api IO schema, which only exists inside ComfyUI. Guard
|
|
# the import so the package root still imports cleanly without ComfyUI (e.g. the
|
|
# dev venv / test collection); ComfyUI itself always provides comfy_api.
|
|
try:
|
|
from comfy_api.latest import ComfyExtension, IO # noqa: E402
|
|
except ModuleNotFoundError:
|
|
ComfyExtension = None
|
|
else:
|
|
from imagent.node_edit import OpenAIImageEdit # noqa: E402
|
|
from imagent.node_generate import OpenAIImageGenerate # noqa: E402
|
|
|
|
class ImagentExtension(ComfyExtension):
|
|
async def get_node_list(self) -> list[type[IO.ComfyNode]]:
|
|
return [OpenAIImageGenerate, OpenAIImageEdit]
|
|
|
|
async def comfy_entrypoint() -> ImagentExtension:
|
|
return ImagentExtension()
|