Extensions/comfyui_jas_nodes
ComfyUI Extension

comfyui_jas_nodes

Custom ComfyUI nodes for direct image generation and editing with OpenAI, Gemini, and OpenRouter API providers without extra account flows.

By reducm·Created 4 months ago·Updated 4 months ago· 0
reducm/comfyui_jas_nodes
Nodes
On cloudLocal install
Stars0
Updated4 months ago
Readme

comfyui_jas_nodes

English | 中文

Custom ComfyUI nodes for direct image generation and image editing with OpenAI, Gemini, and OpenRouter.

Contents

Why this project exists

Many existing nodes, including some official or provider-branded ones, are tied to extra account login flows, provider dashboards, or platform-specific registration steps. This project is meant to stay simple: set an API key, restart ComfyUI, and use the nodes.

If you already have a valid API key, you should not need an extra Comfy account login just to run image generation or image editing.

What it includes

  • Direct OpenAI text-to-image node
  • Direct OpenAI image-edit node
  • Direct Gemini / Nano Banana text-to-image node
  • Direct Gemini / Nano Banana image-edit node
  • OpenRouter text-to-image node
  • OpenRouter image-edit node
  • Example workflows for each provider

Supported nodes

  • JAS OpenAI Text to Image [set OPENAI_API_KEY]
  • JAS OpenAI Image Edit [set OPENAI_API_KEY]
  • JAS Nano Banana Text to Image [set GEMINI_API_KEY]
  • JAS Nano Banana Image Edit [set GEMINI_API_KEY]
  • JAS OpenRouter Text to Image [set OPENROUTER_API_KEY]
  • JAS OpenRouter Image Edit [set OPENROUTER_API_KEY]

Supported providers and models

  • OpenAI: direct images API usage
  • Gemini: direct Gemini image generation / editing usage
  • OpenRouter: currently supports openai/gpt-5.4-image-2 and google/gemini-3.1-flash-image-preview

Requirements

  • ComfyUI
  • Python environment used by ComfyUI
  • requests
  • Valid provider API key for the nodes you plan to use

Install dependency:

python -m pip install -r requirements.txt

Quick Start

  1. Clone this repository into ComfyUI/custom_nodes/comfyui_jas_nodes
  2. Install dependencies with python -m pip install -r requirements.txt
  3. Set the API key you want to use, such as OPENAI_API_KEY, GEMINI_API_KEY, or OPENROUTER_API_KEY
  4. Restart ComfyUI
  5. Search for JAS in the node menu and load one of the example workflows if needed

Installation

Recommended cross-platform layout

Place this project inside your ComfyUI custom node directory:

ComfyUI/custom_nodes/comfyui_jas_nodes

Then restart ComfyUI.

If you are developing locally and prefer to keep the source outside your main ComfyUI directory, you can also use your own loader or symlink workflow, but that is optional and not required for normal users.

API key setup

OpenAI

Required environment variable:

OPENAI_API_KEY

Gemini

Required environment variable:

GEMINI_API_KEY

Alternative supported variable:

GOOGLE_API_KEY

OpenRouter

Required environment variable:

OPENROUTER_API_KEY

Environment variable setup on Windows

Current PowerShell session:

$env:OPENAI_API_KEY = "sk-..."
$env:GEMINI_API_KEY = "your-gemini-key"
$env:OPENROUTER_API_KEY = "your-openrouter-key"

Current CMD session:

set OPENAI_API_KEY=sk-...
set GEMINI_API_KEY=your-gemini-key
set OPENROUTER_API_KEY=your-openrouter-key

Persist for the current Windows user:

[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "sk-...", "User")
[Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "your-gemini-key", "User")
[Environment]::SetEnvironmentVariable("OPENROUTER_API_KEY", "your-openrouter-key", "User")

Notes:

  • User writes to your Windows user environment variables, not system-wide machine variables
  • You will usually see these values in the Windows environment variable UI under user variables
  • After changing them, restart ComfyUI completely
  • Already-open terminals do not automatically pick up newly saved environment variables

Environment variable setup on macOS and Linux

Temporary shell session:

export OPENAI_API_KEY="sk-..."
export GEMINI_API_KEY="your-gemini-key"
export OPENROUTER_API_KEY="your-openrouter-key"

Persist for bash:

echo 'export OPENAI_API_KEY="sk-..."' >> ~/.bashrc
echo 'export GEMINI_API_KEY="your-gemini-key"' >> ~/.bashrc
echo 'export OPENROUTER_API_KEY="your-openrouter-key"' >> ~/.bashrc
source ~/.bashrc

Persist for zsh:

echo 'export OPENAI_API_KEY="sk-..."' >> ~/.zshrc
echo 'export GEMINI_API_KEY="your-gemini-key"' >> ~/.zshrc
echo 'export OPENROUTER_API_KEY="your-openrouter-key"' >> ~/.zshrc
source ~/.zshrc

Then restart ComfyUI from a shell that has those variables.

Base URL support

The nodes expose configurable base_url inputs.

  • OpenAI nodes default to https://api.openai.com/v1
  • Gemini nodes default to https://generativelanguage.googleapis.com/v1beta/models
  • OpenRouter nodes default to https://openrouter.ai/api/v1/chat/completions

This lets you point compatible nodes to alternate endpoints when needed.

OpenRouter image edit sizing behavior

OpenRouter image edit supports:

  • aspect_ratio=source
  • preserve_source_size=true

When enabled, the node derives aspect ratio from the input image and also sends the original WIDTHxHEIGHT as image_config.size.

Important: this is a request to the upstream API. The final returned size still depends on what the selected model and provider actually honor.

Example workflows

  • example/text_to_image_example.json
  • example/image_edit_example.json
  • example/nanobanana_text_to_image_example.json
  • example/nanobanana_image_edit_example.json
  • example/openrouter_text_to_image_example.json
  • example/openrouter_image_edit_example.json

The image edit examples expect an input image such as example_input.png in your ComfyUI input directory, unless you change the filename after importing.

Development workflow

If you change node code in nodes.py:

  1. Save the file
  2. Fully restart ComfyUI
  3. Test the node again

In the current project structure, most normal feature work only needs changes in nodes.py. You usually do not need to edit __init__.py unless you change how modules are exported or loaded.

Standard usage for other users

For a normal installation, users do not need any special loader file outside this repository.

The standard setup is simply:

  1. Clone this repository into ComfyUI/custom_nodes/comfyui_jas_nodes
  2. Set the needed API key
  3. Restart ComfyUI

That is enough because this repository already exports its node mappings through its own __init__.py.

Debugging

  • Start ComfyUI from a terminal so Python import errors and API failures stay visible
  • If the nodes do not appear, check startup logs for comfyui_jas_nodes
  • If a provider request fails, the node raises the HTTP status and response body when available
  • If OpenRouter returns text instead of an image, that usually means the model refused the request or answered in text only
  • OpenAI edit supports optional MASK; mask requires exactly one input image

Notes

  • OpenAI image generation is not guaranteed to be deterministic even if a seed-like field is present in workflow compatibility logic
  • Gemini image generation is also not guaranteed to be deterministic even if a seed is accepted upstream
  • Custom resolution is currently validated for gpt-image-2 only in the direct OpenAI nodes
  • Transparent background is blocked for gpt-image-2 in the direct OpenAI nodes to match current API constraints

Security reminder

  • Keep API keys in environment variables instead of hardcoding them into workflows or source files
  • Do not commit real keys, .env files, or private configuration files

License

This project is licensed under the MIT License. See LICENSE.