Nodes/Grok Imagine (xAI)/Grok Imagine Generate (xAI)
ComfyUI Node

Grok Imagine Generate (xAI)

The Four-Cent Image Node, Explained

By Slartibart23·Created 3 months ago·Updated 21 days ago· 1
Grok Imagine Generate (xAI)
    • images
    • prompt
    • info
    ◄prompt►
    ◄modelgrok-imagine-image-2.0►
    ◄n1►
    ◄aspect_ratioauto►
    ◄resolution1k►
    ◄qualitylow►
    ◄seed0►
    ◄fail_on_moderationfalse►
    ◄custom_model►
    ◄api_key►
    ◄api_key_filegrok_api_key.txt►
    ◄base_urlhttps://api.x.ai/v1►
    ◄timeout_seconds300►

    Why you'd reach for it

    Grok Imagine has no weights. You can't download it, you can't quantize it, you can't run it on a 3090 - the node is an HTTP client with your xAI key attached, posting to api.x.ai/v1/images/generations and dropping the result back into your graph as an ordinary IMAGE batch. From the canvas it looks like any other generator.

    The reason people bother is price. grok-imagine-image-2.0 at 1k on the low tier is $0.04 an image, and the read going around during 2026 was that it lands embarrassingly close to the expensive closed models for a tenth of the money. In one +240 thread about Qwen Image 2.0 staying closed, the argument that kept resurfacing was simply: why would anyone bother, when grok-imagine-image is $0.02 and isn't that far off Nano Banana. That's the whole case. Cheap closed-model quality, inside the same graph as your upscaler and your masks.

    The cost is the usual one for API nodes: prompts leave your machine and the provider's filter applies, with nothing local to patch around it. Whether that's a dealbreaker is your call, not the node's.

    The inputs you actually touch

    prompt is the whole job. image-2.0 follows plain sentences closely - name the subject, action, setting, camera, light, style - and it's unusually good at text, so put any lettering in quotes and say where it goes. There's no negative prompt field, because the API has no concept of one. Say what you want instead of what you don't.

    Three widgets get people in trouble, and they're worth understanding before you spend anything:

    • resolution is size, and there are exactly two classes: 1k (~1 MP) and 2k (~4 MP). 2k costs $0.02 more per image.
    • quality is detail tier, not size: low, medium, auto, default. The author defaults it to low so the billed tier is visible instead of hidden behind auto. Medium is roughly double the price. The classic mistake is cranking resolution and wondering why the image is still softish - that's the other dial.
    • n (1–10) generates the batch in one request. Every image is billed, so n: 10 at 2k/medium is $0.80 in one click. The console prints the estimate before it sends anything.

    seed deserves a sentence of its own: it is not sent to the API and results are not reproducible. It's a cache-breaker. Leave it fixed and an unchanged graph reuses Comfy's cached output and costs nothing; randomize it (or change it by hand) and you get a fresh, freshly-billed request. fail_on_moderation turns a filtered result into a hard queue error instead of a silently degraded image - useful when you'd rather stop than ship something the API declined. custom_model overrides the dropdown if xAI ships a new ID before the pack updates.

    Worth knowing: quality is only sent when the model starts with grok-imagine-image-2.0. On the older grok-imagine-image it's ignored, which is correct, not broken.

    Outputs and where they go

    images is the batch - wire it into an upscaler, a Preview, or Grok Image Save if you want numbered files in a folder you chose instead of the ComfyUI output directory. prompt is the text exactly as sent, which is what you connect to a save node's prompt_text so your .txt sidecars are never empty. info is one line of facts: model actually used, true pixel size of each image, requested resolution and quality, the moderation flag, and estimated vs. billed cost in USD. When a bill surprises you, info is where you find out why.

    Install

    ComfyUI Manager, search Grok Imagine, or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Slartibart23/comfyui-grok-imagine-video
    ..\..\python_embeded\python.exe -m pip install -r comfyui-grok-imagine-video\requirements.txt
    

    (Portable Windows layout above; on Linux/mac use your own python against the same requirements file.) Then restart ComfyUI and hit Ctrl+F5 in the browser once - that loads the pack's preview script. Dependencies are light: requests, numpy, Pillow, imageio, imageio-ffmpeg. No models to download, no VRAM used.

    The key is found in this order: the api_key widget, then XAI_API_KEY, then grok_api_key.txt sitting in the ComfyUI root, the portable root, or the pack folder. Use the env var or the file - the widget value gets baked into any workflow you export.

    When it goes sideways

    No xAI API key found means all three lookups missed; get a key at console.x.ai and drop it in ComfyUI/grok_api_key.txt. HTTP 429 and the 5xx range are retried automatically a couple of times with backoff before failing, so a single blip usually isn't your problem. grok-imagine-image-quality is retired on 2026-11-02 and the node warns if it's still selected - after that it's served by 2.0 at low quality, so just switch to grok-imagine-image-2.0. And if a result comes back visibly blander than your prompt, check info for the moderation flag before blaming the model.

    CategoryGrok/Imagine

    Inputs (13)

    NameTypeDefaultDescription
    promptSTRINGWhat to generate. image-2.0 follows detailed instructions closely: name subject, action, setting, camera, light and style in plain sentences. It is strong at typography - put any text in quotes and say where it goes. No negative prompt exists; say what you want instead of what you don't.
    modelCOMBOgrok-imagine-image-2.0Image model. grok-imagine-image-2.0 is current (best quality, sharp text, quality tiers, 15 ratios, 5 edit sources). grok-imagine-image = 1.0, $0.02/image, lower quality. grok-imagine-image-quality is RETIRED on 2026-11-02 and then served by 2.0 at low quality.
    nINT11–10How many images to generate in one request (1-10). Every image is billed; the console prints the estimated total before the request.
    aspect_ratioCOMBOautoOutput aspect ratio. 'auto' lets the model pick based on the prompt. 21:9 = cinematic widescreen, 5:2 = wide banner, 19.5:9 / 20:9 = phone screens. Pixel size = this ratio x the resolution class.
    resolutionCOMBO1kIMAGE SIZE. The API offers exactly two classes: 1k (about 1 megapixel, e.g. 1024x1024 or 1344x768) and 2k (about 4 megapixels, e.g. 2048x2048 or 2688x1536). Independent of 'quality'. Price impact on image-2.0: +$0.02 per image for 2k. The real pixel size of every result is shown on the 'info' output.
    qualityCOMBOlowDETAIL / COMPUTE TIER, NOT image size (see resolution). image-2.0 only. low: fastest, cheapest. medium: more compute per image - finer detail in skin, fabric, small text; recommended for edits and final renders. auto: the API decides (currently low for generation, medium for editing) and bills what it served. default: parameter not sent (= auto). Prices per image: 1k/low $0.04, 2k/low $0.06, 1k/medium $0.06, 2k/medium $0.08. Older models ignore this - keep 'default' there.
    seedINT00–18446744073709550000Cache-breaker only (not sent to the API; results are not reproducible). randomize = new request every queue run; fixed = reuse the cached result for identical settings (no cost).
    fail_on_moderationoptBOOLEANfalseIf the API flags a result as not passing content moderation (respect_moderation=false), stop the queue with an error instead of silently passing the filtered image on. The request is billed either way; 'info' always shows the flag.
    custom_modeloptSTRINGType any model ID here to override the dropdown (e.g. a brand-new release). Leave empty to use the dropdown. See console.x.ai or GET /v1/models for valid IDs.
    api_keyoptSTRINGYour xAI API key. NOT recommended here — it is saved inside exported workflows. Prefer the XAI_API_KEY environment variable or the key file.
    api_key_fileoptSTRINGgrok_api_key.txtText file containing only the key. Searched in the ComfyUI root, the portable root and this pack's folder (or give an absolute path). The same file serves the Prompt Forge pack.
    base_urloptSTRINGhttps://api.x.ai/v1API base URL. Leave at https://api.x.ai/v1 unless you use a proxy.
    timeout_secondsoptINT30030–1200Seconds to wait for one HTTP response before giving up.

    Outputs (3)

    NameTypeDescription
    imagesIMAGEAll generated images as one IMAGE batch (n images, same size). Connect to Preview/Save Image, an upscaler, or the Edit/Video nodes.
    promptSTRINGThe prompt exactly as sent, for Save nodes (prompt_text) or captions.
    infoSTRINGOne line of facts about this request: model the API used, true pixel size of each image, requested resolution/quality, moderation flag, estimated and real billed cost in USD.