The Art of Prompting for Image Generation
On this page
Lesson rewritten on November 3, 2026 based on xAI’s Image Prompting Guide, written for
grok-imagine-image-2.0: subject comes before style, light is described by its source, direction, and hardness, a list of forbidden items is replaced by what you want to see, and an isolated image is described in four to six sentences. The previous version gave a limit of “1,024 characters” that appears on no current xAI page, and advised “specifying what you do not want to see,” which the guide discourages. Source: Image Prompting Guide.
What matters first: the subject
xAI’s prompting guide sets a simple success criterion: an image is good if its subject matches the prompt. Palette, grain, and style come later. This hierarchy dictates all writing: a prompt that starts with mood, film stock, or a list of forbidden items gets a polished scene around an approximate subject.
Open with a sentence that establishes the subject: what it is, its state or form, what holds it, and where it sits.
- Vague: “a teapot”
- Precise: “A black cast iron teapot, lid slightly ajar, sitting on a cork trivet, on a slate table near a window.”
Then describe the subject like an object you could point to: every important element, named by the form it takes in the image (“a cable-knit sweater” rather than “a sweater”); quantities (“two mugs”, “a single open book”); and the viewing angle, stated once and unambiguously (“three-quarter view at table height”, “vertical overhead shot”).
A fixed six-step order
The guide proposes an order to keep from one prompt to the next, especially in a series:
- The subject: what it is, its form, its support, the decor
- Details and focal point: key elements, materials, quantities, viewing angle
- Art direction: major color zones and two or three accessories, each named
- Light: its source, direction, hardness
- Colors: those of the subject and those of the background, separately
- Composition: framing, what the frame cuts, what stays sharp—a single scene
Write it all in prose, like the description of a single photograph. A sentence that sounds like an instruction (“make the sweater darker”) works poorly in generation: the model has no “before” to compare it to, and reads it as an attribute of the image to produce.
Style, in its place
Style remains a powerful lever, provided it comes after the subject. Naming a movement or technique steers the output:
styles = [
"watercolor",
"impressionist oil painting",
"digital art",
"hyperrealistic photography",
"minimalist flat design",
"manga",
"art deco",
"retro pixel art",
]
Lesson 11 shows how to describe what makes a style rather than just naming it, and how to keep it consistent across a series.
Light: source, direction, hardness
“Beautiful light” means nothing to the model. Describe light like a lighting director: where it comes from, which side, whether it is hard or diffuse, and what the shadows and reflections look like. “Desk lamp on the left, hard light, sharp pen shadow on the page” gets drawn; “warm ambiance” gets guessed.
Two precautions come from the guide. Ask for exposure bright enough for the subject to read: “slightly underexposed” or “crushed shadows” darken the whole image. And leave out optical or printing defects—color fringing, dust, scratches—which the model draws as real defects.
Describe what you want to see
Describe a material positively: “patinated brass, with lighter edges” gives the model a surface to render, “not too new” gives it nothing. The same principle applies to exclusions. The guide observes that a long list of forbidden items is easily ignored, and fills the prompt with objects that end up appearing. Keep a constraint only when it concerns a count or a specific object, and associate it with what you want: “a single pencil, placed to the right of the notebook”.
Also name each object for what it is—a cup, a mug, and a bowl are three different objects—and describe a texture only once: repeated, it ends up applied to the wrong surface.
How long?
For an isolated image, xAI’s guide counts four to six sentences: the subject and its details, then the decor, light, and framing. This is not a ceiling, it is the order of magnitude of a complete description; xAI pages do not specify a maximum prompt length.
Comparative examples
See the difference between a basic prompt and a prompt built in the guide’s order, with the OpenAI client configured in Lesson 1:
# Basic prompt
basic = client.images.generate(
model="grok-imagine-image-2.0",
prompt="a desk",
)
# Structured prompt: subject, details, art direction, light, colors, framing
optimized = client.images.generate(
model="grok-imagine-image-2.0",
prompt=(
"A light oak desk holding a turned-off monitor, a potted monstera, "
"and a steaming mug of coffee, seen from a three-quarter view at "
"seating height. The surface shows wood grain and a gray felt desk pad. "
"Off-white wall, shelf on the left with three books. "
"Soft natural light from a large window on the right, "
"light shadows, honey wood and deep green foliage. "
"35 mm photography, entire desk in frame, mug in sharp focus."
),
)
The first leaves everything to the model: framing, light, objects, style. The second decides each of these points, in the same order as all prompts in the series.
Generate or edit?
The guide distinguishes two situations. Generate when there is no image yet, or when the subject itself is wrong: a different object, a missing element, a wrong count. Edit when the subject and layout are good and only one to three details need changing: the modification first, then a sentence that keeps the same subject, the same angle, and the same framing. Editing is covered in Lessons 5–8.
Iterate methodically
Judge each image against the original prompt, even after several tries: is the subject the one named, is every element visible in the described form, is the count right, is each object the correct one, is the image bright enough to see the subject? A successful background around the wrong subject remains a failure.
Keep the prompt next to the image, and on the next turn change only the detail that failed: the rest of the prompt stays in place, and the subject and layout do not move. If a correction does not take, change words rather than insisting: point to the part of the image to correct and describe what it should show.
response = client.images.generate(
model="grok-imagine-image-2.0",
prompt="Your prompt, modified on a single detail",
n=4,
extra_body={"aspect_ratio": "3:2"},
)
for i, image in enumerate(response.data):
print(f"Variation {i+1}: {image.url}")
Generating several variations of the same prompt (n ranges from 1 to 10) helps separate what holds to the prompt from what holds to chance. Also keep the same aspect_ratio across a series, so the images go together.
Key takeaways
- Subject first: a successful image is one whose subject matches the prompt
- Keep a fixed order: subject, details, art direction, light, colors, framing
- Describe light by its source, direction, and hardness, and ask for an image bright enough
- Describe what you want to see rather than a list of forbidden items
- Count four to six sentences for an isolated image
- Iterate one detail at a time, judging each image against the original prompt