Nodes/ComfyUI-NanoGPT_ImageGeneration/NanoGPT - Image Generation
ComfyUI Node

NanoGPT - Image Generation

This 'NanoGPT' node is just an API call

By myonmu0·Created 5 months ago·Updated 5 months ago· 0
NanoGPT - Image Generation
  • image
  • image
prompt
modelqwen-image
size1024x1024
step30
strength1.00
seed43

The name is doing a lot of work. "NanoGPT - Image Generation" sounds like a local model, but there is no model here - no downloaded weights, no sampler, no GPU. This is a thin HTTP client with a ComfyUI face. It takes your prompt, POSTs it to nano-gpt.com's image generation API, and converts the PNG that comes back into a normal IMAGE tensor you can save, preview, or upscale. If your whole reason for being in ComfyUI is running open weights on your own card, this is the opposite of that. But if you already pay for a NanoGPT plan and your VRAM is a tired 8GB card, it's a genuinely handy bridge.

The author built it to use the image models bundled in the $8 NanoGPT plan from inside ComfyUI, and to hand that workflow off to SillyTavern, OpenWebUI, and similar tools via File > Export (API). In that sense it's not competing with local generation at all - it's an API node for people who already bought the subscription.

How it works

Open nodes.py and you'll see the whole thing: one requests.post to https://nano-gpt.com/api/v1/images/generations with your key in the Authorization header. The model runs on NanoGPT's servers; all your machine does is ship JSON and decode base64. That's why there are no heavy dependencies and no model downloads - the only real requirement is an internet connection and money on your NanoGPT account.

Two details are worth knowing because they bite. First, IS_CHANGED returns NaN, which tells ComfyUI to skip caching and always re-run. Every time you hit queue, it's another paid API call - no free reruns like you'd get locally. Second, the "NanoGPT" model names are really hosted versions of open models: qwen-image is Alibaba's Qwen-Image (the 20B text-rendering and editing line), and z-image-turbo is Tongyi's Z-Image Turbo, the 6B model that took the local photorealism crown from Flux. The irony is these are Apache 2.0 weights you could run locally for free - you're renting what you could download, which only makes sense when you don't have the hardware.

The inputs that matter

You'll actually touch three of these:

  • prompt - multiline, so write your whole scene here.
  • model - defaults to qwen-image. This is also the only model the author says works for image editing; z-image-turbo, chroma, and hidream are generation-only. The README is explicit about it, and it matches reality.
  • size - one of six fixed presets: 1024x1024, 1168x880, 880x1168, 1312x1312, 1312x1024, 1024x1312. Pick landscape or portrait variants here; there's no free-form resolution.

The rest: step (default 30) maps to the API's num_inference_steps, strength (0 to 1) blends an input image, seed (default 43) controls reproducibility server-side, and the optional image input lets you wire in a reference image for editing - the node converts it to base64 and rejects anything over 4MB with an exception. The single output, image, plugs straight into SaveImage or PreviewImage.

Installing it

ComfyUI Manager: search for ComfyUI-NanoGPT_ImageGeneration and install. Or by hand:

cd ComfyUI/custom_nodes/
git clone https://github.com/myonmu0/ComfyUI-NanoGPT_ImageGeneration

Then restart ComfyUI. There's no requirements.txt - everything it imports (requests, torch, PIL, torchvision) ships with a standard ComfyUI install, though cv2 is only guaranteed if your setup includes opencv. If you hit a ModuleNotFoundError: cv2, pip install opencv-python fixes it.

Here's the gotcha that gets everyone: you must edit nodes.py and hardcode your API key into the file before anything works.

API_KEY = "sk-nano-XXXX-XXXX-XXXX-XXXX-XXXX"

There's no widget for it, no config file, no .env. Which means your key sits in plaintext inside your custom_nodes folder - don't share the folder, don't push it to a repo, and don't expose ComfyUI to the internet with it in there. Updating the pack may also wipe the key, so you'll re-add it. Clunky, but a one-time thing.

Troubleshooting

  • 401 / authorization errors - you didn't add the key, or you edited the wrong copy of nodes.py. Set API_KEY, restart, retry.
  • Edit fails on z-image-turbo / chroma / hidream - expected. The author only supports editing on qwen-image. Switch the model.
  • "Reference image should be smaller than 4MB" - downscale the image before wiring it into the input; a big batch from another node will trip this.
  • Every queue run spends your balance - that's the NaN cache-buster doing its job. There's no local cache to lean on; treat this node like a paid remote service, because it is one.

Is it for you? If you own a capable GPU, run Qwen-Image and Z-Image locally - they're free and uncensored. If you don't, and you're already on the $8 plan, this is a painless way to get those models into your ComfyUI graph.

CategoryNanoGPT

Inputs (7)

NameTypeDefaultDescription
promptSTRING
modelCOMBOqwen-image4 options: qwen-image, z-image-turbo, chroma, hidream
sizeCOMBO1024x10246 options: 1024x1024, 1168x880, 880x1168, 1312x1312, 1312x1024, 1024x1312
stepINT30
strengthFLOAT1.000–1
seedINT43
imageoptIMAGE

Outputs (1)

NameTypeDescription
imageIMAGE