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

# GPT-Image-1.5 - Image Edit

> Quality gpt image 1.5 image edit. Efficient AI photo retouching and creative effects for modern designers.

## Authentication

1. Sign up for a GPTProto account at [https://gptproto.com](https://gptproto.com)
2. Navigate to the API Keys section in your dashboard
3. Generate a new API key (sk-xxxxx)
4. Copy and securely store your API key
   For authentication details, please refer to the [Authentication](https://docs.gptproto.com/authentication) section.

## Initiate Request

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://gptproto.com/v1/images/edits' \
  --header 'Authorization: GPTPROTO_API_KEY' \
  --form 'model="gpt-image-1.5"' \
  --form 'image[]=@"/path/to/file"' \
  --form 'prompt="Put a hat on the cat"'

  ```

  ```javascript JavaScript theme={null}
  const axios = require('axios');
  const FormData = require('form-data');
  const fs = require('fs');
  let data = new FormData();
  data.append('model', 'gpt-image-1.5');
  data.append('image[]', fs.createReadStream('/path/to/file'));
  data.append('prompt', 'Put a hat on the cat');

  let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://gptproto.com/v1/images/edits',
    headers: { 
      'Authorization': 'GPTPROTO_API_KEY', 
      ...data.getHeaders()
    },
    data : data
  };

  axios.request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });


  ```

  ```python Python theme={null}
  import http.client
  import mimetypes
  from codecs import encode

  conn = http.client.HTTPSConnection("gptproto.com")
  dataList = []
  boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
  dataList.append(encode('--' + boundary))
  dataList.append(encode('Content-Disposition: form-data; name=model;'))

  dataList.append(encode('Content-Type: {}'.format('text/plain')))
  dataList.append(encode(''))

  dataList.append(encode("gpt-image-1.5"))
  dataList.append(encode('--' + boundary))
  dataList.append(encode('Content-Disposition: form-data; name=image[]; filename={0}'.format('file')))

  fileType = mimetypes.guess_type('/path/to/file')[0] or 'application/octet-stream'
  dataList.append(encode('Content-Type: {}'.format(fileType)))
  dataList.append(encode(''))

  with open('/path/to/file', 'rb') as f:
    dataList.append(f.read())
  dataList.append(encode('--' + boundary))
  dataList.append(encode('Content-Disposition: form-data; name=prompt;'))

  dataList.append(encode('Content-Type: {}'.format('text/plain')))
  dataList.append(encode(''))

  dataList.append(encode("Put a hat on the cat"))
  dataList.append(encode('--'+boundary+'--'))
  dataList.append(encode(''))
  body = b'\r\n'.join(dataList)
  payload = body
  headers = {
    'Authorization': 'GPTPROTO_API_KEY',
    'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
  }
  conn.request("POST", "/v1/images/edits", payload, headers)
  res = conn.getresponse()
  data = res.read()
  print(data.decode("utf-8"))

  ```

  ```go Go theme={null}
  package main

  import (
    "fmt"
    "bytes"
    "mime/multipart"
    "os"
    "path/filepath"
    "net/http"
    "io"
  )

  func main() {

    url := "https://gptproto.com/v1/images/edits"
    method := "POST"

    payload := &bytes.Buffer{}
    writer := multipart.NewWriter(payload)
    _ = writer.WriteField("model", "gpt-image-1.5")
    file, errFile2 := os.Open("/path/to/file")
    defer file.Close()
    part2,
           errFile2 := writer.CreateFormFile("image[]",filepath.Base("/path/to/file"))
    _, errFile2 = io.Copy(part2, file)
    if errFile2 != nil {
      fmt.Println(errFile2)
      return
    }
    _ = writer.WriteField("prompt", "Put a hat on the cat")
    err := writer.Close()
    if err != nil {
      fmt.Println(err)
      return
    }


    client := &http.Client {
    }
    req, err := http.NewRequest(method, url, payload)

    if err != nil {
      fmt.Println(err)
      return
    }
    req.Header.Add("Authorization", "GPTPROTO_API_KEY")

    req.Header.Set("Content-Type", writer.FormDataContentType())
    res, err := client.Do(req)
    if err != nil {
      fmt.Println(err)
      return
    }
    defer res.Body.Close()

    body, err := io.ReadAll(res.Body)
    if err != nil {
      fmt.Println(err)
      return
    }
    fmt.Println(string(body))
  }

  ```
</CodeGroup>

<Accordion title="Response Example">
  ```json theme={null}
  {
    "created": 1776843003,
    "background": "opaque",
    "data": [
      {
        "b64_json": "<BASE64_DATA>"
      }
    ],
    "output_format": "png",
    "quality": "low",
    "size": "1024x1024",
    "usage": {
      "input_tokens": 8,
      "input_tokens_details": {
        "image_tokens": 0,
        "text_tokens": 8
      },
      "output_tokens": 196,
      "output_tokens_details": {
        "image_tokens": 196,
        "text_tokens": 0
      },
      "total_tokens": 204
    }
  }
  ```
</Accordion>

## Parameters

<Tabs>
  <Tab title="Text to Image" icon="image">
    | Parameter            | Type    | Required | Default       | Range                                                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                             |
    | -------------------- | ------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | `model`              | string  | ✅ Yes    | `gpt-image-1` | `gpt-image-1`<br />`gpt-image-1-mini`<br />`gpt-image-1.5`<br />`gpt-image-2`                                                                                 | The model to use for image generation. Defaults to gpt-image-1.                                                                                                                                                                                                                                                                         |
    | `prompt`             | string  | ✅ Yes    | -             | -                                                                                                                                                             | A text description of the desired image(s). The maximum length is 32000 characters.                                                                                                                                                                                                                                                     |
    | `n`                  | integer | ❌ No     | `1`           | `1-10`                                                                                                                                                        | The number of images to generate. Must be between 1 and 10.                                                                                                                                                                                                                                                                             |
    | `size`               | string  | ❌ No     | `auto`        | `auto`<br />`1024x1024`<br />`1536x1024`<br />`1024x1536`<br />`2048x2048`<br />`2048x1152`<br />`3840x2160`<br />`2160x3840`<br />*or any valid custom size* | The size of the generated images. For gpt-image-1: one of auto, 1024x1024, 1536x1024, or 1024x1536. For gpt-image-2: supports arbitrary resolutions (max edge ≤ 3840px, both sides must be multiples of 16px, aspect ratio ≤ 3:1, total pixels between 655,360 and 8,294,400). Outputs exceeding 2560×1440 are considered experimental. |
    | `quality`            | string  | ❌ No     | `auto`        | `auto`<br />`high`<br />`medium`<br />`low`                                                                                                                   | The quality of the generated images. One of auto, low, medium, or high. Defaults to auto. Not supported by `-plus` suffixed models.                                                                                                                                                                                                     |
    | `background`         | string  | ❌ No     | `auto`        | `opaque`<br />`auto`<br />`transparent`                                                                                                                       | Allows to set transparency for the background of the generated image(s). `transparent` is only supported by gpt-image-1 (not gpt-image-2) and requires output\_format to be png or webp. When auto is used, the model will automatically determine the best background.                                                                 |
    | `moderation`         | string  | ❌ No     | `auto`        | `low`<br />`auto`                                                                                                                                             | Content moderation level for generated images. `low` is less restrictive, `auto` is the default.                                                                                                                                                                                                                                        |
    | `output_format`      | string  | ❌ No     | `auto`        | `auto`<br />`png`<br />`jpeg`<br />`webp`                                                                                                                     | The output format of the generated image(s). Defaults to auto. jpeg is faster than png for latency-sensitive scenarios.                                                                                                                                                                                                                 |
    | `output_compression` | integer | ❌ No     | `100`         | `0-100`                                                                                                                                                       | The compression level (0-100%) for the output image. Only applicable with webp or jpeg format. Defaults to 100.                                                                                                                                                                                                                         |
    | `stream`             | boolean | ❌ No     | `false`       | `true`<br />`false`                                                                                                                                           | Whether to stream the response in real-time. When enabled, partial images can be received during generation.                                                                                                                                                                                                                            |
    | `partial_images`     | integer | ❌ No     | -             | `0-3`                                                                                                                                                         | The number of partial images to receive during streaming. Only used when stream is true. Each partial image incurs an additional 100 image output tokens.                                                                                                                                                                               |
    | `user`               | string  | ❌ No     | -             | -                                                                                                                                                             | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.                                                                                                                                                                                                                                      |
  </Tab>

  <Tab title="Image Edit" icon="pencil">
    | Parameter            | Type    | Required | Default       | Range                                                                                                                                                         | Description                                                                                                                                                                                                                                                                    |
    | -------------------- | ------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    | `model`              | string  | ✅ Yes    | `gpt-image-1` | `gpt-image-1`<br />`gpt-image-1-mini`<br />`gpt-image-1.5`<br />`gpt-image-2`                                                                                 | The model to use for image editing. Defaults to gpt-image-1.                                                                                                                                                                                                                   |
    | `prompt`             | string  | ✅ Yes    | -             | 1–32000 chars                                                                                                                                                 | A text description of the desired image edit.                                                                                                                                                                                                                                  |
    | `images`             | file    | ✅ Yes    | -             | max 16 images<br />\< 50MB each                                                                                                                               | The input image(s) to edit. Each image should be a png, webp, or jpg file. You can provide up to 16 images.                                                                                                                                                                    |
    | `mask`               | file    | ❌ No     | -             | -                                                                                                                                                             | An additional image whose fully transparent areas indicate where the image should be edited.                                                                                                                                                                                   |
    | `input_fidelity`     | string  | ❌ No     | -             | `high`<br />`low`                                                                                                                                             | Controls how faithfully the model preserves the original input image. Only supported by gpt-image-1. gpt-image-2 always uses high fidelity.                                                                                                                                    |
    | `n`                  | integer | ❌ No     | `1`           | `1-10`                                                                                                                                                        | The number of images to generate. Must be between 1 and 10.                                                                                                                                                                                                                    |
    | `size`               | string  | ❌ No     | `auto`        | `auto`<br />`1024x1024`<br />`1536x1024`<br />`1024x1536`<br />`2048x2048`<br />`2048x1152`<br />`3840x2160`<br />`2160x3840`<br />*or any valid custom size* | The size of the generated images. For gpt-image-1: one of auto, 1024x1024, 1536x1024, or 1024x1536. For gpt-image-2: supports arbitrary resolutions (max edge ≤ 3840px, both sides must be multiples of 16px, aspect ratio ≤ 3:1, total pixels between 655,360 and 8,294,400). |
    | `quality`            | string  | ❌ No     | `auto`        | `auto`<br />`high`<br />`medium`<br />`low`                                                                                                                   | The quality of the generated images. One of auto, low, medium, or high. Defaults to auto. Not supported by `-plus` suffixed models.                                                                                                                                            |
    | `background`         | string  | ❌ No     | `auto`        | `opaque`<br />`auto`<br />`transparent`                                                                                                                       | Allows to set transparency for the background of the generated image(s). `transparent` is only supported by gpt-image-1 (not gpt-image-2) and requires output\_format to be png or webp.                                                                                       |
    | `moderation`         | string  | ❌ No     | `auto`        | `low`<br />`auto`                                                                                                                                             | Content moderation level for generated images. `low` is less restrictive, `auto` is the default.                                                                                                                                                                               |
    | `output_format`      | string  | ❌ No     | `auto`        | `auto`<br />`png`<br />`jpeg`<br />`webp`                                                                                                                     | The output format of the generated image(s). Defaults to auto. jpeg is faster than png for latency-sensitive scenarios.                                                                                                                                                        |
    | `output_compression` | integer | ❌ No     | `100`         | `0-100`                                                                                                                                                       | The compression level (0-100%) for the output image. Only applicable with webp or jpeg format. Defaults to 100.                                                                                                                                                                |
    | `stream`             | boolean | ❌ No     | `false`       | `true`<br />`false`                                                                                                                                           | Whether to stream the response in real-time. When enabled, partial images can be received during generation.                                                                                                                                                                   |
    | `partial_images`     | integer | ❌ No     | -             | `0-3`                                                                                                                                                         | The number of partial images to receive during streaming. Only used when stream is true. Set to 0 for a single streaming event with the complete image. Each partial image incurs an additional 100 image output tokens.                                                       |
    | `user`               | string  | ❌ No     | -             | -                                                                                                                                                             | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.                                                                                                                                                                             |
  </Tab>
</Tabs>

## Error Codes

### Common Error Codes

| Error Code | Error Name               | Description                                                                                                       |
| ---------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| 401        | Unauthorized             | API key is missing or invalid                                                                                     |
| 403        | Forbidden                | Your API key doesn't have permission to access this resource, or insufficient balance for the requested operation |
| 429        | Too Many Requests        | You've exceeded your rate limit                                                                                   |
| 500        | Internal server error    | An internal server error occurred                                                                                 |
| 503        | Content policy violation | Content blocked due to safety concerns (actual status code is 400)                                                |
