## Basic model info

Model name: xai/grok-imagine-image-2
Model description: xAI's Grok Imagine Image 2.0 — text-to-image generation and editing with a quality control and output up to 2k


## Model inputs

- prompt (required): Text prompt for image generation or editing (string)
- image (optional): Input image for editing. When provided, the model edits this image based on the prompt. Supports jpg, jpeg, png, webp. (string)
- aspect_ratio (optional): Aspect ratio of the generated image. Ignored when editing an image. (string)
- resolution (optional): Resolution of the generated image. (string)
- quality (optional): Generation quality. 'medium' produces the best results, 'low' is faster and cheaper. (string)


## Model output schema

{
  "type": "string",
  "title": "Output",
  "format": "uri"
}

If the input or output schema includes a format of URI, it is referring to a file.


## Example inputs and outputs

Use these example outputs to better understand the types of inputs the model accepts, and the types of outputs the model returns:

### Example (https://replicate.com/p/rdvnjtp3a5rmy0czzk99phf7s8)

#### Input

```json
{
  "prompt": "a mountain scene",
  "quality": "medium",
  "resolution": "2k",
  "aspect_ratio": "1:1"
}
```

#### Output

```json
"https://replicate.delivery/xezq/7xjZZz5y2R78OB4qZ4QGutcCOYiECRhWBLixw1OR3lo8bvwF/tmpz5prikwc.jpg"
```


## Model readme

> # Grok Imagine Image 2.0
> 
> xAI's Grok Imagine Image 2.0 generates and edits images from text prompts. It's the latest generation of the Imagine image family. A `quality` setting lets you trade speed and cost for detail, and it outputs up to 2k resolution in a wide range of aspect ratios.
> 
> ## Overview
> 
> Grok Imagine Image 2.0 is a general-purpose text-to-image model. Give it a prompt and it generates an image. Give it an image plus a prompt and it edits that image. It handles detailed prompts covering subject, style, lighting, composition, and real-world entities like brands, places, and named objects.
> 
> If you want the fastest, cheapest generations, use [xai/grok-imagine-image](https://replicate.com/xai/grok-imagine-image). [xai/grok-imagine-image-quality](https://replicate.com/xai/grok-imagine-image-quality) now runs on this model at `low` quality.
> 
> ## What you can do with it
> 
> **Generate images from text**
> 
> Describe what you want and the model creates it. Detailed prompts covering subject, style, mood, lighting, and composition work best.
> 
> **Edit existing images**
> 
> Upload an image and describe the change you want. The model applies your edit while keeping the overall structure of the original.
> 
> **Tune quality vs. speed**
> 
> The `quality` input accepts `low` or `medium` (default `medium`). Use `low` for quick drafts or high-volume jobs, and `medium` for finer detail on final output.
> 
> **Output at 1k or 2k**
> 
> Pick `1k` (1024px on the long edge) for a faster image, or `2k` (2048px on the long edge) for a high-resolution deliverable. The default is `2k`.
> 
> **Multiple aspect ratios**
> 
> Choose from square, landscape, portrait, ultrawide, and vertical ratios to match wherever the image is going.
> 
> ## How to write prompts
> 
> **Be specific.** Detailed prompts beat short ones. Describe the subject, setting, lighting, mood, and style. For example: "A vintage travel poster for Kyoto, Mount Fuji in the background, cherry blossoms in the foreground, art deco typography, rich color blocks."
> 
> **Name real things directly.** If you want a specific brand, location, or recognizable subject, name it. The model handles real-world knowledge well.
> 
> **Add style at the end.** Append style directives to steer the look: "oil painting style," "anime illustration," "cinematic 35mm film photography."
> 
> **For editing, describe the change, not the whole image.** "Make the sky a dramatic sunset" works better than re-describing every element.
> 
> ## Inputs
> 
> - **prompt**: text description of the image you want, or instructions for how to edit the input image
> - **image** (optional): input image for editing. When you provide one, the model edits it based on the prompt. Supports jpg, jpeg, png, webp.
> - **aspect_ratio**: output aspect ratio (default `1:1`). Ignored when editing an image.
> - **resolution**: `1k` or `2k` (default `2k`)
> - **quality**: `low` or `medium` (default `medium`)
> 
> ## Pricing
> 
> | | 1k output | 2k output |
> | --- | --- | --- |
> | `low` quality | $0.04 | $0.06 |
> | `medium` quality | $0.06 | $0.08 |
> | Plus per input image (when editing) | $0.01 | $0.01 |
> 
> With the defaults (2k, `medium`), a text-to-image generation costs $0.08. A 1k `low` edit with one input image costs $0.04 + $0.01 = $0.05.
> 
> ## Try it yourself
> 
> Run Grok Imagine Image 2.0 from the Playground at [replicate.com/playground](https://replicate.com/playground), or call it from your code with the Replicate API.

