# Save the image to a file
with open("woman_with_logo.png", "wb") as f:
    f.write(image_bytes)
```

| Input 1                                                                 | Input 2                                                                | Output                                                                                                |
| ----------------------------------------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| ![A woman](https://cdn.openai.com/API/docs/images/woman_futuristic.jpg) | ![A brain logo](https://cdn.openai.com/API/docs/images/brain_logo.png) | ![The woman with a brain logo on her top](https://cdn.openai.com/API/docs/images/woman_with_logo.jpg) |

Prompt: Add the logo to the woman's top, as if stamped into the fabric.

Keep in mind that when using high input fidelity, more image input tokens will
be used per request. To understand the costs implications, refer to our
[vision costs](https://platform.openai.com/docs/guides/images-vision?api-mode=responses#calculating-costs)
section.

## Customize Image Output

You can configure the following output options:

- **Size**: Image dimensions (e.g., `1024x1024`, `1024x1536`)
- **Quality**: Rendering quality (e.g. `low`, `medium`, `high`)
- **Format**: File output format
- **Compression**: Compression level (0-100%) for JPEG and WebP formats
- **Background**: Transparent or opaque

`size`, `quality`, and `background` support the `auto` option, where the model
will automatically select the best option based on the prompt.

### Size and quality options

Square images with standard quality are the fastest to generate. The default
size is 1024x1024 pixels.

<table><tbody><tr><td>Available sizes</td><td><ul><li><code>1024x1024</code> (square) - <code>1536x1024</code> (landscape) - <code>1024x1536</code> (portrait)</li><li><code>auto</code> (default)</li></ul></td></tr><tr><td>Quality options</td><td>- <code>low</code> - <code>medium</code> - <code>high</code> - <code>auto</code> (default)</td></tr></tbody></table>

### Output format

The Image API returns base64-encoded image data. The default format is `png`,
but you can also request `jpeg` or `webp`.

If using `jpeg` or `webp`, you can also specify the `output_compression`
parameter to control the compression level (0-100%). For example,
`output_compression=50` will compress the image by 50%.

Using `jpeg` is faster than `png`, so you should prioritize this format if
latency is a concern.

### Transparency

The `gpt-image-1` model supports transparent backgrounds. To enable
transparency, set the `background` parameter to `transparent`.

It is only supported with the `png` and `webp` output formats.

Transparency works best when setting the quality to `medium` or `high`.

Responses API

```python
import openai
import base64

response = openai.responses.create(
    model="gpt-5",
    input="Draw a 2D pixel art style sprite sheet of a tabby gray cat",
    tools=[
        {
            "type": "image_generation",
            "background": "transparent",
            "quality": "high",
        }
    ],
)

image_data = [
    output.result
    for output in response.output
    if output.type == "image_generation_call"
]

if image_data:
    image_base64 = image_data[0]

    with open("sprite.png", "wb") as f:
        f.write(base64.b64decode(image_base64))
```

```javascript
import fs from "fs";
import OpenAI from "openai";

const client = new OpenAI();

const response = await client.responses.create({
  model: "gpt-5",
  input: "Draw a 2D pixel art style sprite sheet of a tabby gray cat",
  tools: [
    {
      type: "image_generation",
      background: "transparent",
      quality: "high",
    },
  ],
});

const imageData = response.output
  .filter((output) => output.type === "image_generation_call")
  .map((output) => output.result);

if (imageData.length > 0) {
  const imageBase64 = imageData[0];
  const imageBuffer = Buffer.from(imageBase64, "base64");
  fs.writeFileSync("sprite.png", imageBuffer);
}
```

Image API

```javascript
import OpenAI from "openai";
import fs from "fs";
const openai = new OpenAI();

const result = await openai.images.generate({
  model: "gpt-image-1",
  prompt: "Draw a 2D pixel art style sprite sheet of a tabby gray cat",
  size: "1024x1024",
  background: "transparent",
  quality: "high",
});

// Save the image to a file
const image_base64 = result.data[0].b64_json;
const image_bytes = Buffer.from(image_base64, "base64");
fs.writeFileSync("sprite.png", image_bytes);
```

```python
from openai import OpenAI
import base64
client = OpenAI()

result = client.images.generate(
    model="gpt-image-1",
    prompt="Draw a 2D pixel art style sprite sheet of a tabby gray cat",
    size="1024x1024",
    background="transparent",
    quality="high",
)

image_base64 = result.json()["data"][0]["b64_json"]
image_bytes = base64.b64decode(image_base64)