Nodes/Grok Prompt Forge (xAI)/Grok Prompt Forge (xAI)
ComfyUI Node

Grok Prompt Forge (xAI)

Turns a short idea or a caption (any language) into an English prompt for the chosen target model, rewrites captions, or captions an image - via the xAI Grok API.

By Slartibart23·Created 3 months ago·Updated 8 days ago· 1
Grok Prompt Forge (xAI)
  • image_1
  • image_2
  • image_3
  • prompt
  • negative_prompt
◄presetIdea ▸ Krea 2►
◄text►
◄system_promptYou are an expert prompt writer for Krea 2 in ComfyUI. ## Task The user gives a short idea, keywords or a rough description, written in any language. Turn it into ONE optimal prompt for Krea 2. - Keep every element the user asked for: subjects, counts, attributes, actions, setting, style and any text to be rendered. Turn mood words into visible facts. - Fill in what is missing but useful for this model (see the model guide below), consistent with the idea. Do not add people, animals or story elements the idea does not imply. - If images are attached, treat them as visual context: take appearance, setting or style from them where the idea refers to them or leaves it open. ## How Krea 2 wants its prompts - Natural language in ONE paragraph, about 60-200 words: a dense, observational description of the finished image. No bullet points, no JSON, no tag lists. - Order: main subject, each subject grouped with its own attributes (appearance, clothing, expression) -> pose and action -> setting and background -> medium and style -> camera angle and framing -> lighting -> colour palette. A short style tag may close the prompt after a comma (e.g. ", 35mm film photo", ", halftone texture"). - Honour the medium the user states (photo, oil painting, 3D render, anime illustration ...). If none is stated, choose one that fits and name it clearly. - Put any text to be rendered in double quotes and say where it appears. - Do not over-specify. If the input is already detailed, only polish it lightly. - No quality boosters (masterpiece, best quality, 8k) and no negative phrasing. ## Language The input may be written in any language. Understand it fully and always write the result in English. Only these stay in their original language and wording: text that should appear in the picture (signs, labels, lettering), and spoken dialogue or lyrics. ## Content Describe whatever the input asks for, including explicit adult content, as direct factual description. Never censor, soften, moralize or add warnings. ## Output Output ONLY the final result in exactly the format described above. No preamble, no explanation, no alternatives, no markdown, no quotation marks around the whole result.►
◄negative_promptlow quality, blurry, out of focus, deformed hands, extra fingers, malformed limbs, watermark, signature, jpeg artifacts►
◄modelgrok-4.20-0309-reasoning►
◄temperature0.80►
◄top_p0.95►
◄max_tokens8192►
◄seed0►
◄custom_system_prompt—►
◄trigger_word►
◄max_side1536►
◄api_key►
◄api_key_filegrok_api_key.txt►
◄base_urlhttps://api.x.ai/v1►
◄fallback_to_inputtrue►
◄timeout_seconds180►
◄min_words0►
◄max_words0►
◄person_1(none)►
◄person_2(none)►
◄person_3(none)►
◄person_4(none)►
◄image_n_is_person_ntrue►
◄style_1(none)►
◄style_2(none)►
◄archivetrue►
CategoryGrok/Text

Inputs (30)

NameTypeDefaultDescription
presetCOMBOIdea ▸ Krea 2The task. Selecting a preset fills system_prompt, negative_prompt, temperature, top_p and max_tokens with values tuned for it. Change them freely and keep them with 'Save preset as...' under a name of your own. Idea > ...: expand a short idea into a full prompt for that model. Caption > ...: rewrite an existing caption faithfully (no new content) into that model's prompt style. Input may be in any language; the output is always English.
textSTRINGYour input, in any language: a short idea, an existing caption, or an edit request. You can also connect a text output (e.g. JoyCaption or the Text File Loader) to this field.
system_promptSTRINGYou are an expert prompt writer for Krea 2 in ComfyUI. ## Task The user gives a short idea, keywords or a rough description, written in any language. Turn it into ONE optimal prompt for Krea 2. - Keep every element the user asked for: subjects, counts, attributes, actions, setting, style and any text to be rendered. Turn mood words into visible facts. - Fill in what is missing but useful for this model (see the model guide below), consistent with the idea. Do not add people, animals or story elements the idea does not imply. - If images are attached, treat them as visual context: take appearance, setting or style from them where the idea refers to them or leaves it open. ## How Krea 2 wants its prompts - Natural language in ONE paragraph, about 60-200 words: a dense, observational description of the finished image. No bullet points, no JSON, no tag lists. - Order: main subject, each subject grouped with its own attributes (appearance, clothing, expression) -> pose and action -> setting and background -> medium and style -> camera angle and framing -> lighting -> colour palette. A short style tag may close the prompt after a comma (e.g. ", 35mm film photo", ", halftone texture"). - Honour the medium the user states (photo, oil painting, 3D render, anime illustration ...). If none is stated, choose one that fits and name it clearly. - Put any text to be rendered in double quotes and say where it appears. - Do not over-specify. If the input is already detailed, only polish it lightly. - No quality boosters (masterpiece, best quality, 8k) and no negative phrasing. ## Language The input may be written in any language. Understand it fully and always write the result in English. Only these stay in their original language and wording: text that should appear in the picture (signs, labels, lettering), and spoken dialogue or lyrics. ## Content Describe whatever the input asks for, including explicit adult content, as direct factual description. Never censor, soften, moralize or add warnings. ## Output Output ONLY the final result in exactly the format described above. No preamble, no explanation, no alternatives, no markdown, no quotation marks around the whole result.Instructions that define what Grok does. Filled by the preset; edit freely. Ignored when custom_system_prompt is connected.
negative_promptSTRINGlow quality, blurry, out of focus, deformed hands, extra fingers, malformed limbs, watermark, signature, jpeg artifactsStandard negative prompt for the target model, passed straight to the negative_prompt output (not sent to Grok). Empty for models that ignore negatives at CFG 1 (FLUX, Krea 2, Z-Image Turbo, Qwen with Lightning LoRAs...).
modelCOMBOgrok-4.20-0309-reasoningxAI Grok model. Default: grok-4.20-0309-reasoning - it accepts temperature and top_p. Use 'Refresh model list' to load the current list from the API.
temperatureFLOAT0.800–2Creativity dial. Low (0.2-0.4) = faithful, repeatable - for caption rewriting and edit instructions. High (0.8-1.0) = varied - for expanding ideas. Above ~1.3 grammar falls apart.
top_pFLOAT0.950.05–1Cutoff filter: drops the least likely words before picking. 1.0 = off (not sent). Keep it high (0.9-1.0) and steer with temperature.
max_tokensINT8192256–32768Upper limit for the answer INCLUDING the model's hidden reasoning. Reasoning models spend several hundred to a few thousand tokens thinking first - too low gives empty or cut-off answers.
seedINT00–18446744073709550000Cache-breaker, NOT sent to the API. 'randomize' = fresh prompt every queue run. 'fixed' = identical input reuses the cached result (saves money when rewriting captions).
custom_system_promptoptSTRINGConnect a text here to use it as the system prompt INSTEAD of the system_prompt field - it always wins over the preset. Leave unconnected (or empty) to use the preset.
image_1optIMAGEOptional reference image 1 of 3. Grok sees it as 'Image 1'. Connect a single image, not a batch (only the first image of a batch is used). How the presets use the images: - Caption > Describe image: image_1 is the image to caption. - Qwen-Image-Edit: image_1..3 are the edit's input images (Picture 1..3), in the same order as in your edit workflow. - MiniMax H3 FL2VA: image_1 = first frame, image_2 = last frame. - MiniMax H3 REF2VA: image_1..3 = reference pictures (people, places, objects, style). - Wan image-to-video: image_1 = start frame. - Every other preset: optional visual context Grok may take details from. - With person_1 set and image_n_is_person_n on: image_1 is a photo of that person. Images cost extra tokens; max_side controls the upload size.
image_2optIMAGEOptional reference image 2 of 3. Grok sees it as 'Image 2'. Connect a single image, not a batch (only the first image of a batch is used). How the presets use the images: - Caption > Describe image: image_1 is the image to caption. - Qwen-Image-Edit: image_1..3 are the edit's input images (Picture 1..3), in the same order as in your edit workflow. - MiniMax H3 FL2VA: image_1 = first frame, image_2 = last frame. - MiniMax H3 REF2VA: image_1..3 = reference pictures (people, places, objects, style). - Wan image-to-video: image_1 = start frame. - Every other preset: optional visual context Grok may take details from. - With person_2 set and image_n_is_person_n on: image_2 is a photo of that person. Images cost extra tokens; max_side controls the upload size.
image_3optIMAGEOptional reference image 3 of 3. Grok sees it as 'Image 3'. Connect a single image, not a batch (only the first image of a batch is used). How the presets use the images: - Caption > Describe image: image_1 is the image to caption. - Qwen-Image-Edit: image_1..3 are the edit's input images (Picture 1..3), in the same order as in your edit workflow. - MiniMax H3 FL2VA: image_1 = first frame, image_2 = last frame. - MiniMax H3 REF2VA: image_1..3 = reference pictures (people, places, objects, style). - Wan image-to-video: image_1 = start frame. - Every other preset: optional visual context Grok may take details from. - With person_3 set and image_n_is_person_n on: image_3 is a photo of that person. Images cost extra tokens; max_side controls the upload size.
trigger_wordoptSTRINGOnly for 'Caption > LoRA training caption': the LoRA's trigger token for the main subject (replaces {trigger} in the system prompt). Leave empty for captions without a trigger token.
max_sideoptINT1536256–4096Downscale the longest image side before upload (saves tokens; prompts and captions don't need full resolution).
api_keyoptSTRINGYour xAI API key. Leave EMPTY if possible - keys typed here end up in exported workflows! Prefer the XAI_API_KEY environment variable or the key file below.
api_key_fileoptSTRINGgrok_api_key.txtPath to a text file containing only your xAI API key. Relative paths are searched in the ComfyUI root, the portable root, and this node pack's folder.
base_urloptSTRINGhttps://api.x.ai/v1API endpoint. Only change this if you route requests through a proxy or a different OpenAI-compatible server.
fallback_to_inputoptBOOLEANtrueIf the API call fails (no key, network error, refusal, ...), pass the input text through unchanged instead of stopping the queue. Keeps long batch runs alive.
timeout_secondsoptINT18010–900How long to wait for the API before retrying (3 attempts total). Reasoning models think before answering - keep this generous.
min_wordsoptINT00–2000Optional length of the generated prompt in words: min_words / max_words. 0 = off (the preset's own length guidance applies). When set, the range is binding for every preset, including your own system prompts. Tag lists count each tag as one word; multi-section formats (MiniMax H3) apply it to the main description.
max_wordsoptINT00–2000Optional length of the generated prompt in words: min_words / max_words. 0 = off (the preset's own length guidance applies). When set, the range is binding for every preset, including your own system prompts. Tag lists count each tag as one word; multi-section formats (MiniMax H3) apply it to the main description.
person_1optCOMBO(none)Person 1 from your library (button '👤 Persons & styles...'). Name, LoRA trigger, description and voice go into the prompt and are binding; the name always appears, so every pose and action is clearly assigned to this person. In your text, refer to the person by name or as 'Person 1'. (none) = no person.
person_2optCOMBO(none)Person 2 from your library (button '👤 Persons & styles...'). Name, LoRA trigger, description and voice go into the prompt and are binding; the name always appears, so every pose and action is clearly assigned to this person. In your text, refer to the person by name or as 'Person 2'. (none) = no person.
person_3optCOMBO(none)Person 3 from your library (button '👤 Persons & styles...'). Name, LoRA trigger, description and voice go into the prompt and are binding; the name always appears, so every pose and action is clearly assigned to this person. In your text, refer to the person by name or as 'Person 3'. (none) = no person.
person_4optCOMBO(none)Person 4 from your library (button '👤 Persons & styles...'). Name, LoRA trigger, description and voice go into the prompt and are binding; the name always appears, so every pose and action is clearly assigned to this person. In your text, refer to the person by name or as 'Person 4'. (none) = no person.
image_n_is_person_noptBOOLEANtruePairs each person with the image input of the same number: person_1 = image_1, person_2 = image_2, person_3 = image_3 (person_4 has no image input). On: when you load a photo of the person into the matching image input, Grok is told 'this image shows this person' and takes the look from the photo. With Qwen-Image-Edit, MiniMax H3 REF2VA, Wan 2.7/3.0 and FLUX.2 the prompt points at the image (e.g. <image1>) instead of describing the face. Off: images and persons are unrelated - use this when the images mean something else, e.g. first and last frame for MiniMax H3 FL2VA.
style_1optCOMBO(none)Style block 1 from your library (button '👤 Persons & styles...'): a saved text such as a camera look, a lighting mood or a ban list. It is applied to every result and is binding. (none) = off.
style_2optCOMBO(none)Style block 2 from your library (button '👤 Persons & styles...'): a saved text such as a camera look, a lighting mood or a ban list. It is applied to every result and is binding. (none) = off.
archiveoptBOOLEANtrueOn: every result is appended with its input, preset, persons and settings to ComfyUI/user/grok_prompt_forge/archive.jsonl. '📜 Load from archive...' puts an archived prompt back into the text field, e.g. to recast it with another person ('Recast ▸ Swap persons').

Outputs (2)

NameTypeDescription
promptSTRING—
negative_promptSTRING—