Grok Generate Image
Closed-source image gen inside ComfyUI, with zero local VRAM spent
- image
- image1
- image2
- image3
- image4
- history
- image
- text
- history
xAI's Grok image generation doesn't run on your GPU - it runs on xAI's servers, which means the only thing this node needs from your machine is a network connection and an API key. Grok Generate Image takes a text prompt, calls the xAI API, and returns the generated image as a normal IMAGE tensor plus the model's text response. No model download, no VRAM pressure, no diffusion pipeline - it's a cloud call wearing a node's clothes.
The context makes the appeal concrete. Grok's image model has a reputation in the community for being unusually unrestricted (the KB's closed-source roundup has it as the least restrictive of the big commercial image models, with everyone early on suspecting it was secretly Flux under the hood), and because it's an API, it runs on hardware that could never dream of local generation. Real people use exactly this pattern on 8GB laptops and old cards - research threads show Grok-image-in-ComfyUI being used as the way to get strong closed-source generations on a 3050. If you want that capability piped into a workflow as a graph object, this is the node.
How it works
It builds a chat-style request and sends it to the xAI API (default model grok-imagine-image, or grok-4 for text-style replies). The chat_template field controls how your system_prompt and prompt get wrapped into the request - the default uses <-system-> / <-user-> tags, and you can edit it to match xAI's current template format. You get controls for aspect_ratio and resolution (both default "auto"), how many images to produce (n, up to 10), seed for reproducibility, and response_format (default "url" - the node downloads the returned image URL and decodes it to a tensor). There are optional image / image1-image4 inputs if you want image-editing or reference workflows, plus history and an extra JSON field for new API params.
The inputs that matter
api_key- your xAI key. Leave it blank and the node falls back to theXAI_API_KEY/GROK_API_KEYenv vars or anapi_key.jsonentry - which is the more sensible way to store it.prompt- the actual generation prompt.system_prompt- sets overall style; useful for a consistent look across many generations.aspect_ratio/resolution/n/seed- the generation controls you'll touch most.
Three outputs: image (the generated tensor), text (the model's text reply), and history (for chaining into conversation).
Installing it
It's part of ComfyUI-YogurtNodes. Install via ComfyUI Manager (search "ComfyUI-YogurtNodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
Restart ComfyUI; it's under "Yogurt Nodes". You need an xAI API key - a paid account at console.x.ai.
Where people get burned
The chat_template is the sharp edge: if xAI changes their prompt format, an old template can silently produce degraded results - if generations start looking off, check whether the template still matches the API docs. Watch your usage cost too; image generation bills per request and a looping workflow adds up. And when the node errors with an auth message, remember the key lookup order: the api_key field wins, then the config file, then environment variables - an empty field doesn't mean "no key anywhere", it means "keep looking".
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | API key for accessing xAI API | |
| base_url | STRING | Base URL for xAI API (leave blank for official API) | |
| model_name | STRING | grok-imagine-image | xAI image generation model name |
| system_prompt | STRING | System-level prompt that affects the overall image generation style | |
| prompt | STRING | Main prompt content for image generation | |
| aspect_ratio | COMBO | auto | Aspect ratio for generated images |
| resolution | COMBO | auto | Resolution for generated images |
| n | INT | 11–10 | Number of images to generate |
| response_format | COMBO | url | Response format for generated images |
| retry_count | INT | 1 | Number of retries when request fails |
| chat_template | STRING | <-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user-> | Content template for the image generation prompt |
| proxy_url | STRING | 代理URL,格式: protocol://user:pass@addr:port,支持http,https,socks5,socks5h | |
| seed | INT | -1-1–2147483647 | Random seed for generation (-1 for random) |
| timeout | INT | 00–2147483647 | Timeout for the request in seconds, 0 means no timeout |
| imageopt | IMAGE | — | |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| historyopt | HISTORY | — | |
| extraopt | STRING | {} | Extra parameters for the request, in JSON format |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| text | STRING | — |
| history | HISTORY | — |