Better Grok
Grok draws, edits, and chats — from one ComfyUI node
- prompt_images
- IMAGE
- STRING
Grok's image generation - xAI's Aurora-style stack - has one thing going for it that no other big closed model can claim: it's the least restrictive of the lot, and it's been impressively photoreal since day one. The catch has always been that it lives inside X/Twitter. Better Grok drags it into ComfyUI, and then goes further: the same node also does image editing from reference images and plain text chat, all with a reasoning-effort dial.
Like its sibling Better Gemini (same pack, Google's side of things), this is not local generation. It's a paid API call per request, and nothing runs on your GPU. What you're buying is a cloud image model that snaps into your graph - Grok's output drops out of the IMAGE socket, so you can hand it to a local upscaler or feed it back into your own workflow instead of screenshotting a website.
How it works
There's no xAI SDK to fight. The node talks straight to api.x.ai using the Python standard library, and it requests response_format="b64_json", so the returned images arrive as tensors directly - no temporary URL to go download. That sounds like an implementation detail, but it's why this node feels like a native one.
Two details in the README are worth knowing because they're traps the author already hit for you. First, api.x.ai can reject the default Python-urllib user-agent with a Cloudflare 1010 error, so the client sends an explicit application User-Agent - if you ever see that error, updating and restarting ComfyUI is the fix. Second, image edits use xAI's JSON-based /v1/images/edits endpoint and send your ComfyUI IMAGE inputs as PNG data URIs; multiple prompt images are supported for edit and merge workflows. Text mode uses /v1/responses with store=false (node calls aren't chat sessions) and lets you set reasoning effort.
The inputs and outputs that matter
- model - the dropdown merges image models (
grok-imagine-image,...-pro,...-quality) and language models (grok-latest,grok-4, …) when your key is set. One dropdown, both worlds. - response_modalities -
IMAGEfor pure generation,IMAGE+TEXTto keep the image but also get notes back,TEXTfor a chat call. - prompt_images - this is where the node earns its keep. In image modes they go to the edits API (reference/edit); in
TEXTmode they're sent as chat image inputs. - reasoning_effort -
nonetohigh, but only for text requests; image generation ignores it. - n - how many images per request, up to the documented max of 10.
Outputs are IMAGE and STRING, and the behavior is shared with its Gemini sibling: in TEXT mode the IMAGE socket emits a minimal 1×1 placeholder so the graph stays connected, and any returned text rides STRING. aspect_ratio and resolution are best-effort hints - the model can ignore them, and the node logs a warning if the size doesn't match. cache_outputs reuses identical requests from .cache/, so you don't get re-billed for re-runs.
Install
Manager search "Better-Gemini" is the fast path; otherwise:
cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/Better-Gemini
cd Better-Gemini
pip install -r requirements.txt
Restart ComfyUI and set XAI_API_KEY (or use the node's api_key input). Fun fact: Grok needs no extra Python dependency at all - google-genai in the requirements is only there for the Gemini node in the same pack. What it does need is a recent ComfyUI with the V3 extension loader, since this is a V3-era pack. No key set means the model dropdown falls back to bundled defaults and calls fail at execution with an auth error.
Where people get burned
- The 1×1 placeholder in
TEXTmode is normal - read the result fromSTRING, not the fake image. - Photorealism and "Spicy Mode" looseness mean you should actually read Grok's usage policy; it's the least-censored of the big closed models, and xAI enforces its terms.
- Resolution warnings are the model ignoring a hint, not a broken node.
If you've already got the pack installed for Gemini, this node costs you zero extra setup.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Text prompt for image generation or image editing. | |
| model | COMBO | grok-imagine-image | xAI model name. The dropdown merges image and language models when XAI_API_KEY is available. |
| response_modalities | COMBO | IMAGE | Choose IMAGE output for Grok image generation, IMAGE+TEXT to keep image generation plus node notes, or TEXT to call Grok responses and return the result through STRING. |
| api_keyopt | STRING | Optional. Auto mode prefers this key, then a saved xAI OAuth login, then XAI_API_KEY. | |
| auth_modeopt | COMBO | auto | Auto preserves API-key compatibility and uses OAuth when logged in. OAuth requires the Login button in the node header. |
| reasoning_effortopt | COMBO | none | Reasoning effort for Grok text requests. Image generation ignores this setting. |
| prompt_imagesopt | IMAGE | Optional reference/edit images. IMAGE modes send them to xAI's edits API; TEXT mode sends them as chat image inputs. | |
| aspect_ratioopt | COMBO | auto | If 'auto', xAI chooses. Otherwise requests a specific aspect ratio supported by Grok image generation. |
| resolutionopt | COMBO | auto | Requested output resolution (best-effort). Logs a warning if the returned image size doesn't match. |
| nopt | INT | 11–10 | Number of output images to request. xAI documents a maximum of 10 images per request. |
| cache_outputsopt | BOOLEAN | false | Cache model outputs under .cache and reuse them for identical Grok requests. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| STRING | STRING | — |