Skip to main content
Lesson 12 of 14 · Generate and Edit Images with Grok

Quality Parameter and Render Optimization

Lesson 12 of 14 Updated November 2, 2026 Beginner
On this page
  1. Control Generation Quality
  2. The quality Parameter
  3. Model + quality + resolution Combination
  4. 3-Step Optimization Workflow
  5. Automate Quality Selection
  6. Key Takeaways

Lesson rewritten on November 2, 2026. The previous version described a high value and a quality parameter that had no effect on price, for a “pro” model now retired. According to current xAI documentation, quality is specific to Imagine 2.0, accepts low, medium, and auto, and each image is billed at the quality at which it is served.

Control Generation Quality

The Speed / Quality selector in the Grok Imagine app

In the Grok app, the Speed / Quality selector balances speed and finesse. In the API, this balance involves two choices: the model (Imagine 1.0 or Imagine 2.0) and, for Imagine 2.0, the quality parameter.

The quality Parameter

quality is accepted by grok-imagine-image-2.0, for both generation and editing. Three values:

  • low: the cheapest setting for Imagine 2.0 ($0.04 per image at listed rates), and where requests from the old “pro” model are redirected;
  • medium: more compute per image for finer details, reserve for images where quality matters more than cost;
  • auto: the default value when the parameter is omitted; it currently serves low in generation and medium in editing, and the image is billed at the served quality.

To control both the render and the bill, set the quality explicitly rather than letting auto decide. With the OpenAI SDK pointed at the xAI API, it passes via extra_body:

# Quick draft: Imagine 1.0, the cheapest
brouillon = client.images.generate(
    model="grok-imagine-image",
    prompt="E-commerce website mockup, wireframe style",
)

# Standard visual: Imagine 2.0, low quality
courant = client.images.generate(
    model="grok-imagine-image-2.0",
    prompt="Illustration of a mobile fitness app",
    extra_body={"quality": "low"},
)

# Final visual: Imagine 2.0, medium quality, 2k resolution
final = client.images.generate(
    model="grok-imagine-image-2.0",
    prompt="Advertising poster for a luxury perfume, photorealistic render",
    extra_body={"quality": "medium", "resolution": "2k"},
)

Model + quality + resolution Combination

Three parameters, three effects: the model sets the base price and available features, quality the detail level for Imagine 2.0 (and its rate), resolution the image definition (1k by default, or 2k).

Use CaseModelQualityResolution
Quick prototypeImagine 1.0—1k
Web contentImagine 1.0—1k
Social mediaImagine 2.0low1k
Marketing visualImagine 2.0medium1k
Print, posterImagine 2.0medium2k

3-Step Optimization Workflow

Find the right idea where it’s cheap, refine it, and only pay for the most expensive render on the selected image.

Step 1: Explore

prompts_candidats = [
    "A robot barista making coffee, cartoon style",
    "A robotic arm pouring coffee, realistic style",
    "A mechanical hand holding a steaming cup, steampunk style",
]

for prompt in prompts_candidats:
    response = client.images.generate(
        model="grok-imagine-image",
        prompt=prompt,
        n=3,
    )
    # Cost: 3 x $0.02 = $0.06 per prompt

Step 2: Refine

best_prompt = "A robotic arm pouring coffee, realistic style"

response = client.images.generate(
    model="grok-imagine-image-2.0",
    prompt=best_prompt,
    n=4,
    extra_body={"quality": "low", "resolution": "1k"},
)
# Cost: 4 x $0.04 = $0.16

Step 3: Finalize

response = client.images.generate(
    model="grok-imagine-image-2.0",
    prompt=best_prompt + ", cinematic lighting, fine mechanical details",
    n=2,
    extra_body={"quality": "medium", "resolution": "2k"},
)
# Cost: 2 images at the current "medium" rate

The first two steps cost $0.34 for nine drafts and four variants; only the two final images are billed at the medium rate.

Automate Quality Selection

Centralize this choice in a function to prevent it from scattering across the code. If rates change or a model is added, only one place needs modification.

CONFIGS = {
    "prototype": {"model": "grok-imagine-image", "extra_body": {"resolution": "1k"}},
    "web": {"model": "grok-imagine-image", "extra_body": {"resolution": "1k"}},
    "social": {"model": "grok-imagine-image-2.0", "extra_body": {"quality": "low", "resolution": "1k"}},
    "marketing": {"model": "grok-imagine-image-2.0", "extra_body": {"quality": "medium", "resolution": "1k"}},
    "print": {"model": "grok-imagine-image-2.0", "extra_body": {"quality": "medium", "resolution": "2k"}},
}

def generate_smart(prompt, usage="web"):
    """Generate an image with parameters suited to the use case."""
    config = CONFIGS.get(usage, CONFIGS["web"])
    return client.images.generate(prompt=prompt, **config)

Official sources: Image Generation — Quality · grok-imagine-image-quality Retirement on November 2, 2026 · Pricing

Key Takeaways

  • quality is specific to Imagine 2.0 and accepts low, medium, and auto (default value)
  • The image is billed at the served quality: set the quality explicitly to control the bill
  • With the OpenAI SDK, quality and resolution pass via extra_body
  • 3-step workflow: explore with Imagine 1.0, refine in low, finalize in medium
  • Centralize parameter selection in a configuration function