> ## Documentation Index
> Fetch the complete documentation index at: https://floodgate.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Generation

> Generate and edit images using GPT Image 2 and GPT Image 2.5 with Floodgate.

# Image Generation & Editing

Floodgate provides OpenAI-compatible image endpoints powered by **GPT Image 2** and **GPT Image 2.5**.

<CardGroup cols={2}>
  <Card title="GPT Image 2" icon="bolt">
    **Model ID:** `gpt-image-2`\
    **Pricing:** \$0.30 per request\
    Fast and economical image generation and editing.
  </Card>

  <Card title="GPT Image 2.5" icon="wand-magic-sparkles">
    **Model ID:** `gpt-image-2.5`\
    **Pricing:** \$0.40 per request\
    Flagship multimodal image generation with superior prompt adherence and visual fidelity.
  </Card>
</CardGroup>

***

## Supported Endpoints

| Endpoint | Method | Description |
| :- | :- | :- |
| `/v1/images/generations` | `POST` | Generate new images from a text prompt |
| `/v1/images/edits` | `POST` | Edit existing images or apply inpainting masks |

***

## Image Generations

### Request Parameters

| Parameter | Type | Required | Description |
| :- | :- | :- | :- |
| `prompt` | string | Yes | Text description of the desired image (up to 1,000 characters). |
| `model` | string | No | `gpt-image-2` (default) or `gpt-image-2.5`. |
| `n` | integer | No | Number of images to generate (1–10). Default is 1. |
| `size` | string | No | Image resolution. Supported: `1024x1024` (square), `1536x1024` (landscape), `1024x1536` (portrait). Default is `1024x1024`. |
| `quality` | string | No | Image quality. Supported: `standard`, `high`, `medium`, `low`. Default is `standard`. |
| `response_format` | string | No | Format of generated images: `url` or `b64_json`. |

### Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://api.floodgate.dev/v1/images/generations" \
    -H "Authorization: Bearer $FLOODGATE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-image-2",
      "prompt": "A futuristic city with flying vehicles and glowing neon lights at dusk, cyberpunk style",
      "size": "1024x1024",
      "n": 1
    }'
  ```

  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["FLOODGATE_API_KEY"],
      base_url="https://api.floodgate.dev/v1",
  )

  response = client.images.generate(
      model="gpt-image-2.5",
      prompt="A cozy coffee shop on a rainy afternoon in Tokyo, cinematic lighting",
      size="1536x1024",
      n=1,
  )

  image_url = response.data[0].url
  print("Generated image:", image_url)
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.FLOODGATE_API_KEY,
    baseURL: "https://api.floodgate.dev/v1",
  });

  const response = await client.images.generate({
    model: "gpt-image-2.5",
    prompt: "A majestic mountain landscape reflected in a crystal clear lake during sunrise",
    size: "1024x1024",
    n: 1,
  });

  console.log("Image URL:", response.data[0].url);
  ```
</CodeGroup>

***

## Image Edits & Inpainting

Edit an existing image or provide an optional mask for targeted region edits.

### Request Parameters (`multipart/form-data`)

| Parameter | Type | Required | Description |
| :- | :- | :- | :- |
| `image` | file | Yes | The source image to edit (PNG, WEBP, or JPEG, up to 25MB). |
| `prompt` | string | Yes | Text description of the desired edit or addition. |
| `mask` | file | No | Optional transparent PNG mask (up to 4MB) indicating areas to edit. |
| `model` | string | No | `gpt-image-2` or `gpt-image-2.5`. |
| `size` | string | No | Output size: `1024x1024`, `1536x1024`, or `1024x1536`. |
| `n` | integer | No | Number of output variants (1–10). |

### Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://api.floodgate.dev/v1/images/edits" \
    -H "Authorization: Bearer $FLOODGATE_API_KEY" \
    -F "image=@photo.png" \
    -F "prompt=Add a cute kitten sitting on the bench" \
    -F "model=gpt-image-2" \
    -F "size=1024x1024"
  ```

  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["FLOODGATE_API_KEY"],
      base_url="https://api.floodgate.dev/v1",
  )

  with open("source_image.png", "rb") as img:
      response = client.images.edit(
          image=img,
          model="gpt-image-2.5",
          prompt="Make the background a vibrant sunset over the ocean",
          size="1024x1024",
          n=1,
      )

  print("Edited image URL:", response.data[0].url)
  ```
</CodeGroup>

<Note>
  Image requests are billed on a fixed per-request basis regardless of resolution: **$0.30** for `gpt-image-2` and **$0.40** for `gpt-image-2.5`.
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.