## Basic model info

Model name: openai/gpt-image-2
Model description: OpenAI's image generation and editing model. Create and edit images from text with close instruction following, sharp text rendering, and detailed edits.


## Model inputs

- prompt (required): A text description of the desired image (string)
- openai_api_key (optional): Your OpenAI API key (optional - uses proxy if not provided) (string)
- aspect_ratio (optional): The size of the generated image. Use 'auto' to let the model pick. Sizes above 2560x1440 are experimental and may give more variable results. (string)
- input_images (optional): A list of images to use as input for the generation (array)
- number_of_images (optional): Number of images to generate (1-10) (integer)
- quality (optional): The quality of the generated image (string)
- background (optional): Set whether the background is opaque or choose automatically. GPT Image 2 does not support transparent backgrounds. (string)
- output_compression (optional): Compression level (0-100%) (integer)
- output_format (optional): Output format (string)
- moderation (optional): Content moderation level (string)


## Model output schema

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

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/drk132mwx5rmt0cxp878wad6gc)

#### Input

```json
{
  "prompt": "A photo of a computer screen displaying a Spotify playlist in golden hour evening in a living room with lots of green plants in the background. The playlist says GPT-image-2. caption is \"this new image model from OpenAI is dope.\" and the artists are Replicate. the songs are themes about open source AI and Machine learning. the account name is Replicate. use the logo for replicate as the profile picture and artist image.",
  "quality": "auto",
  "background": "auto",
  "moderation": "auto",
  "aspect_ratio": "3:2",
  "input_images": [
    "https://replicate.delivery/pbxt/Oy2U6Sw4k3ZYEZ5cXeuVJMq8k45GQ17J2iKvt1HcHVUtVj5O/download.jpg"
  ],
  "output_format": "webp",
  "number_of_images": 1,
  "output_compression": 90
}
```

#### Output

```json
[
  "https://replicate.delivery/xezq/AjohJsKVZ26WEZ4tkXI7fKIun2rUbTZxct9EfRKQAPcEWadWA/tmp5ydq16cm.webp"
]
```


## Model readme

> # GPT Image 2
> 
> GPT Image 2 is OpenAI's image generation and editing model. Create images from text, or edit existing images with instructions it follows closely.
> 
> ## What it does
> 
> GPT Image 2 handles two workflows: generating images from text descriptions, and editing existing images with specific instructions. It follows your directions closely and leaves alone the parts you want unchanged.
> 
> When you pass reference images, GPT Image 2 always processes them at high fidelity, so there's no setting for it. Pass one image to edit it, or pass several to combine styles, subjects, or references into a single output.
> 
> ## Key capabilities
> 
> **Photorealism and detail.** Natural-looking images with accurate lighting, believable materials, and rich textures, from candid photography to polished commercial visuals.
> 
> **Text rendering.** Dense text, small lettering, and complex layouts like infographics, UI mockups, and marketing materials.
> 
> **Precise editing.** Targeted changes without redrawing the whole image. The model keeps identity, composition, and lighting while you change specific elements.
> 
> **Style control.** Apply one visual style across different subjects, or transfer the look of one image to another with a short prompt.
> 
> **World knowledge.** Ask for a scene set in "Bethel, New York in August 1969" and the model understands you want Woodstock, because it reasons about the prompt before drawing.
> 
> ## Use cases
> 
> **Image generation.** Infographics, logos, UI mockups, photorealistic scenes, comic strips, and marketing visuals, for both exploration and finished work.
> 
> **Image editing.** Style transfer, virtual clothing try-ons, product mockups, translating text in images, lighting changes, object removal, and scene compositing. Insert people into new scenes while keeping their likeness, or swap furniture in room photos without changing the camera angle.
> 
> **Character consistency.** Build multi-page illustrations where characters look the same from scene to scene, for children's books, storyboards, and campaigns.
> 
> ## How to get good results
> 
> **Be specific.** Instead of "make it better," say "add soft coastal daylight" or "change the red hat to light blue velvet."
> 
> **Use photo language for realism.** Mention lens type, lighting, and framing when you want photorealistic results. "Shot with a 50mm lens, soft daylight, shallow depth of field" gets closer to real photography than generic quality words.
> 
> **Lock what shouldn't change.** When editing, say what must stay the same. "Change only the lighting, preserve the subject's face, pose, and clothing" prevents unwanted changes.
> 
> **Put text in quotes.** For readable text in images, put the exact copy in "quotes" and describe the typography. "Bold sans-serif, centered, high contrast" makes the text easier to read.
> 
> **Iterate with small changes.** Start with a base image, then make one change at a time instead of rewriting everything.
> 
> **Number your input images.** When you pass several images, refer to them by number and describe how they relate: "Apply the style from image 1 to the subject in image 2."
> 
> ## Inputs
> 
> - `prompt`: what you want to generate, or how to edit the input images.
> - `input_images`: one or more reference images, for editing or combining.
> - `aspect_ratio`: `1:1`, `3:2`, `2:3`, `4:3`, `3:4`, `16:9`, `9:16`, or `auto` to let the model pick. You can also set an exact size: `1024x1024`, `1536x1024`, `1024x1536`, `1536x1152`, `1152x1536`, `2048x2048`, `2048x1152`, `1152x2048`, `3840x2160`, or `2160x3840`. Sizes above 2560x1440 are experimental and give more variable results.
> - `quality`: `low`, `medium`, `high`, or `auto` (the default). Lower quality is faster and costs less.
> - `number_of_images`: from 1 to 10 images per run.
> - `output_format`: `webp` (the default), `png`, or `jpeg`.
> - `output_compression`: compression level for `webp` and `jpeg`, from 0 to 100 (default 90).
> - `background`: `auto` (the default) or `opaque`. GPT Image 2 doesn't support transparent backgrounds.
> - `moderation`: `auto` (the default), or `low` for less strict content filtering.
> - `user_id`: an optional ID for your end user, which OpenAI uses to detect abuse.
> - `openai_api_key`: optional. Bring your own OpenAI API key to pay OpenAI directly.
> 
> You can try this model in the [Replicate playground](https://replicate.com/playground).

