xAI Imagine Image Generation (MVP)
Pipe xAI's Grok Imagine straight into your graph
- image
- images
If you've ever generated something in ComfyUI and wished you could hand it to Grok Imagine without leaving the graph, this is the node for you. XAIImagineImage is a one-trick MVP that wraps xAI's hosted Imagine API (grok-imagine-image) as a normal ComfyUI node. Your prompt goes out to xAI's servers, an image comes back as a standard IMAGE tensor, and your GPU doesn't lift a finger.
Before you get too excited: the name is only half a lie. It calls an API, and it needs a key - but there's no model file to download and no VRAM involved. This is a "cloud node," the same species as the Replicate/ideogram API wrappers floating around, and it's here because Grok Imagine's look is genuinely hard to get locally. xAI's image model is closed, autoregressive rather than diffusion-based, and suspected of being Flux-derived - and for a long time it was also the least-restrictive mainstream generator, which is exactly why people kept feeding it their ComfyUI output and wishing for an API. This pack is that wish, in MVP form.
What you actually set
The inputs are few, and only a couple matter:
- prompt - the usual multiline text box. Grok is a conversational model at heart, so it reads natural-language prompts well; the "cheat codes" people used on X largely work here too.
- n - how many images, 1 to 10. Remember this is a paid API: every image is a billable call.
- aspect_ratio - pick from the 8 presets (
1:1,16:9,9:16,4:3,3:4,3:2,2:3), or leave blank for the API default. - image_format -
url(default) orbase64. Both end up the same way on your end; the difference is only how the node pulls the result down. - api_key - paste your key here, or skip it and let the node read the
XAI_API_KEYenvironment variable.
The model dropdown is fixed to grok-imagine-image for now, which is fine - it's the only Imagine model xAI serves. The one input that might surprise you is image (optional): feed in any IMAGE tensor and the node switches to edit mode, converting your first image to base64 and sending it to the API alongside the prompt. It's effectively img2img over the network. Caveat from the source: in this MVP, edit mode forces n down to 1, so don't expect a batch of variations.
The output and where it goes
The single output, images (IMAGE), is a normal ComfyUI batch tensor - the node downloads the API result and converts it to [B, H, W, 3] float. Wire it into a PreviewImage, SaveImage, or straight into whatever processing you have downstream. It behaves like any other IMAGE output, which is the whole appeal: Grok Imagine becomes just another node in your pipeline instead of a browser tab.
Installing it
Through ComfyUI Manager, search for "xAI Imagine Api" and hit install. Or, manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Viningr/comfyui-xai-imagine-api
Then restart ComfyUI. Here's the gotcha that will bite you: the pack's pyproject.toml declares no Python dependencies, and its README is literally the untouched ComfyUI custom-node template. So nothing in the install pulls in the SDK the node needs. Do this yourself or you'll get a ModuleNotFoundError: xai_sdk on startup:
pip install xai-sdk
No model files, no weights, no heavy deps - the whole thing is a thin client. Set your key with export XAI_API_KEY=... (or drop it in the node's api_key field) and you're running.
Where people get burned
- The missing SDK above is the #1 failure. Install the pack, restart, red error - it's almost always
xai_sdkmissing. - The node's own error message tells you what to check: it wraps failures as "xAI Imagine API error (check API key, prompt safety, quotas)". So in practice: bad key, a prompt the safety filter refused, or you ran out of credits. If you're new to xAI's billing, check your quota before blaming the node.
- It's a network call. The
urlformat fetches the image over the wire, so a proxy or flaky connection can fail even after the API succeeds. If that's your world, trybase64. - This is a brand-new, single-node pack (three impressions on comfy.icu tells you everything about adoption). Expect rough edges, and check the repo for updates rather than assuming the README reflects reality.
Worth it? If you already pay for Grok Imagine and want it inside your graph - yes, this is exactly the bridge people were asking for. If you're hoping for a free local alternative, keep looking; that's not what this is.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | A beautiful futuristic cityscape at sunset | — |
| model | COMBO | grok-imagine-image | 1 options: grok-imagine-image |
| n | INT | 11–10 | — |
| image_format | COMBO | url | 2 options: url, base64 |
| aspect_ratio | COMBO | 8 options: , 1:1, 16:9, 9:16, 4:3, 3:4, +2 | |
| imageopt | IMAGE | — | |
| api_keyopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |