ComfyUI Node

Prompt Writer · Grok API

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 29 days ago·Updated 2 days ago· 2
Prompt Writer · Grok API
  • image_1
  • image_2
  • image_3
  • image_4
  • persons
  • prompt
  • negative_prompt
◄presetGeneration ▸ 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, separated into sentences that each end with a period, about 120-250 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 final sentence may name the medium or look (e.g. "Film photo with fine grain.", "Halftone print 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. ## Sentences - Write complete sentences, each ending with a period. - Each sentence makes one clear statement: the look of one subject, their clothing, a pose, an action or interaction, an object, the setting or background, the light, the camera or the style. Split a long description into several short sentences rather than chaining clauses or fragments with commas. - No comma-chained keyword lists. Only labels, tags and term lists that the guide above explicitly asks for (shot labels, timestamps, section names, cinematic setting terms) keep their own form. ## Example of a good result For form, structure and length only - never copy its content, subjects or wording. A young woman with straight black hair sits at a small round café table by a large window. She wears a light grey collared shirt with a loosened black tie. She rests her chin on her right hand and looks straight into the camera with an intense, calm gaze. A white porcelain cup of black coffee stands in front of her, and a thin curl of steam rises from it. A bouquet of pink lilies in a glass vase is blurred in the right foreground. Behind her, the street outside is softly out of focus, and a red tram passes by. The scene is an 85mm portrait photograph taken at eye level with a shallow depth of field. Soft daylight falls in from the left and leaves gentle shadows on the right side of her face. The palette is muted and warm, with greys, soft pinks and deep red accents. Film photo with fine grain. ## 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_nfalse►
◄style_1(none)►
◄style_2(none)►
◄archivetrue►
CategoryPrompt Writer

Inputs (32)

NameTypeDefaultDescription
presetCOMBOGeneration ▸ 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. Generation > ...: expand a short idea or keywords 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, separated into sentences that each end with a period, about 120-250 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 final sentence may name the medium or look (e.g. "Film photo with fine grain.", "Halftone print 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. ## Sentences - Write complete sentences, each ending with a period. - Each sentence makes one clear statement: the look of one subject, their clothing, a pose, an action or interaction, an object, the setting or background, the light, the camera or the style. Split a long description into several short sentences rather than chaining clauses or fragments with commas. - No comma-chained keyword lists. Only labels, tags and term lists that the guide above explicitly asks for (shot labels, timestamps, section names, cinematic setting terms) keep their own form. ## Example of a good result For form, structure and length only - never copy its content, subjects or wording. A young woman with straight black hair sits at a small round café table by a large window. She wears a light grey collared shirt with a loosened black tie. She rests her chin on her right hand and looks straight into the camera with an intense, calm gaze. A white porcelain cup of black coffee stands in front of her, and a thin curl of steam rises from it. A bouquet of pink lilies in a glass vase is blurred in the right foreground. Behind her, the street outside is softly out of focus, and a red tram passes by. The scene is an 85mm portrait photograph taken at eye level with a shallow depth of field. Soft daylight falls in from the left and leaves gentle shadows on the right side of her face. The palette is muted and warm, with greys, soft pinks and deep red accents. Film photo with fine grain. ## 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 the model 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 the model). 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 4. The model 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 (Qwen takes at most 3). - Seedream Edit: image_1..4 are the edit's input images (Image 1..4), in the same order as in the Seedream node. - MiniMax H3 FL2VA: image_1 = first frame, image_2 = last frame. - MiniMax H3 REF2VA: image_1..4 = reference pictures (people, places, objects, style). - Seedance Reference: image_1..4 = reference images (Image 1..4), in the same order as in the Seedance node. - Kling Omni and Grok Imagine reference-to-video: image_1..4 = @Image1..4, in the same order as in the video node. - Image-to-video (Wan, Seedance, Kling, Veo, Grok Imagine): image_1 = start frame (image_2 = last frame for first-last-frame video). - GPT Image, Nano Banana, Grok Imagine Image, Flux 3: image_1..4 = input images for editing or as references. - Every other preset: optional visual context the model 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 4. The model 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 (Qwen takes at most 3). - Seedream Edit: image_1..4 are the edit's input images (Image 1..4), in the same order as in the Seedream node. - MiniMax H3 FL2VA: image_1 = first frame, image_2 = last frame. - MiniMax H3 REF2VA: image_1..4 = reference pictures (people, places, objects, style). - Seedance Reference: image_1..4 = reference images (Image 1..4), in the same order as in the Seedance node. - Kling Omni and Grok Imagine reference-to-video: image_1..4 = @Image1..4, in the same order as in the video node. - Image-to-video (Wan, Seedance, Kling, Veo, Grok Imagine): image_1 = start frame (image_2 = last frame for first-last-frame video). - GPT Image, Nano Banana, Grok Imagine Image, Flux 3: image_1..4 = input images for editing or as references. - Every other preset: optional visual context the model 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 4. The model 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 (Qwen takes at most 3). - Seedream Edit: image_1..4 are the edit's input images (Image 1..4), in the same order as in the Seedream node. - MiniMax H3 FL2VA: image_1 = first frame, image_2 = last frame. - MiniMax H3 REF2VA: image_1..4 = reference pictures (people, places, objects, style). - Seedance Reference: image_1..4 = reference images (Image 1..4), in the same order as in the Seedance node. - Kling Omni and Grok Imagine reference-to-video: image_1..4 = @Image1..4, in the same order as in the video node. - Image-to-video (Wan, Seedance, Kling, Veo, Grok Imagine): image_1 = start frame (image_2 = last frame for first-last-frame video). - GPT Image, Nano Banana, Grok Imagine Image, Flux 3: image_1..4 = input images for editing or as references. - Every other preset: optional visual context the model 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. A library entry whose description starts with 'A group of' is a group of named persons in one slot. Locked while the 'persons' input is connected.
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. A library entry whose description starts with 'A group of' is a group of named persons in one slot. Locked while the 'persons' input is connected.
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. A library entry whose description starts with 'A group of' is a group of named persons in one slot. Locked while the 'persons' input is connected.
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. A library entry whose description starts with 'A group of' is a group of named persons in one slot. Locked while the 'persons' input is connected.
image_n_is_person_noptBOOLEANfalsePairs each person with the image input of the same number: person_1 = image_1, person_2 = image_2, person_3 = image_3, person_4 = image_4. On: when you load a photo of the person into the matching image input, the model 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, Seedream, Seedance, Kling, Grok Imagine, GPT Image, Nano Banana and FLUX the prompt points at the image (e.g. <image1>, Image 1, @Image1) instead of describing the face. Off (default): images and persons are unrelated - e.g. when the images are first and last frame or edit inputs.
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').
image_4optIMAGEOptional reference image 4 of 4. The model sees it as 'Image 4'. 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 (Qwen takes at most 3). - Seedream Edit: image_1..4 are the edit's input images (Image 1..4), in the same order as in the Seedream node. - MiniMax H3 FL2VA: image_1 = first frame, image_2 = last frame. - MiniMax H3 REF2VA: image_1..4 = reference pictures (people, places, objects, style). - Seedance Reference: image_1..4 = reference images (Image 1..4), in the same order as in the Seedance node. - Kling Omni and Grok Imagine reference-to-video: image_1..4 = @Image1..4, in the same order as in the video node. - Image-to-video (Wan, Seedance, Kling, Veo, Grok Imagine): image_1 = start frame (image_2 = last frame for first-last-frame video). - GPT Image, Nano Banana, Grok Imagine Image, Flux 3: image_1..4 = input images for editing or as references. - Every other preset: optional visual context the model may take details from. - With person_4 set and image_n_is_person_n on: image_4 is a photo of that person. Images cost extra tokens; max_side controls the upload size.
personsoptPW_PERSONSOptional: connect 'Prompt Writer · Persons' to choose the persons outside this node - e.g. one cast for several writer nodes. While it is connected, person_1..person_4 on this node are locked and ignored; the slot numbers from the Persons node count (Person 3 there = Person 3 here, also for image_n_is_person_n).

Outputs (2)

NameTypeDescription
promptSTRING—
negative_promptSTRING—