Using wylon image models in ComfyUI
wylon provides an OpenAI Images-compatible synchronous endpoint. ComfyUI can call it through a third-party node that supports a custom api_base; this guide uses comfyui-gpt-image.
Prerequisites
- A working ComfyUI installation.
- Permission to install custom nodes and edit node files.
- A wylon API key and an image model ID, such as
Qwen/Qwen-Image-2512.
1. Install comfyui-gpt-image
In ComfyUI, open Manage Extensions, switch the filter to node packs, search for comfyui-gpt-image, install it, and restart ComfyUI.
gpt-image-1, whose default sizes differ from the current wylon example model. Follow the next steps to edit the node source and restart ComfyUI.2. Confirm model parameters
GET /v1/models confirms model IDs and availability; use the API documentation for parameter limits. Qwen/Qwen-Image-2512 currently supports:
| Parameter | Values | Notes |
|---|---|---|
size | 1328x1328, 1664x928, 928x1664, 1104x1472, 1584x1056 | Default: 1664x928 |
n | 1 | One image per request |
output_format | png | PNG output |
negative_prompt | Supported | Content to exclude |
See the synchronous image API for current details. Do not add inference_steps; it is not a supported request field.
3. Add the size options
Edit ComfyUI/custom_nodes/comfyui-gpt-image/nodes_api.py. Find the fixed size options list and add the wylon model sizes without removing the existing values:
"options": [
"auto", "1024x1024", "1024x1536", "1536x1024",
"1328x1328", "1664x928", "928x1664", "1104x1472", "1584x1056"
],Save the file and restart ComfyUI.
comfyui-gpt-image, check the size options in nodes_api.py again.4. Configure and run the node
Add a Ports OpenAI GPT Image 1 node and configure it:
| Field | Value |
|---|---|
prompt | A non-empty image description |
api_base | https://api.wylon.cn/v1/ (keep the trailing slash) |
auth_token | Your wylon API key |
model | A complete model ID, such as Qwen/Qwen-Image-2512 |
size | A size supported by the model |
n | 1 for this example |
quality, background, moderation | Keep the default values; actual support depends on the selected model |
api_base must end with a slashThe node uses urljoin to construct request URLs. Without the trailing slash, /v1 may be replaced and the request will return 404.Connect the image output to Save Image or Preview Image, then run the workflow.
auth_token may be saved with the workflow. Remove the API key before exporting, uploading, or sharing it, and confirm that the file contains no plaintext credential.5. Improve download resilience
The node makes a second request to download the signed result URL. If the network is unreliable, edit validate_and_cast_response() in nodes_api.py to add a timeout, integrity check, and bounded retries. First add import time near the top of the file, then replace the single-download logic with:
last_err = None
for attempt in range(4):
try:
with requests.get(image_url, stream=True, timeout=(10, 60)) as response:
if response.status_code != 200:
raise Exception("HTTP %s" % response.status_code)
buffer = io.BytesIO()
for chunk in response.iter_content(65536):
if chunk:
buffer.write(chunk)
expected = response.headers.get("Content-Length")
if expected and buffer.tell() < int(expected):
raise Exception("Truncated: %d/%s" % (buffer.tell(), expected))
buffer.seek(0)
img = Image.open(buffer)
img.load()
break
except Exception as error:
last_err = error
time.sleep(2 * (attempt + 1))
else:
raise Exception("Failed to download the image: %s" % last_err)This change retries only the result download. Once generation has been accepted, do not rerun the whole workflow merely because the download failed; doing so may create another billable request.
