---
title: "Edit an image"
description: "Changes the images you send, guided by a prompt. Follows OpenAI's Images API. Send a multipart form, or JSON that names each image by URL. Served by Bedrock, Gemini, MiniMax, OpenAI, OpenRouter, Qwen, Together AI and xAI. Send Respan parameters of a multipart edit in the `X-Data-Respan-Params` header (base64 JSON)."
---

<a id="playground-button:docs/apis/gateway/edit-image"></a>

**POST** `https://gateway.respan.ai/v1/images/edits`

Changes the images you send, guided by a prompt. Follows OpenAI's Images API. Send a multipart form, or JSON that names each image by URL. Served by Bedrock, Gemini, MiniMax, OpenAI, OpenRouter, Qwen, Together AI and xAI. Send Respan parameters of a multipart edit in the `X-Data-Respan-Params` header (base64 JSON).

## Servers

`https://gateway.respan.ai`: Respan gateway

## Authentication

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


## Headers


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| `X-Data-Respan-Params` | `string` | Optional | Base64-encoded JSON object of Respan request parameters. |


## Request body

A request body is required.

### multipart/form-data


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | - |
| `model` | `string` | Required in parent | The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one. |
| `prompt` | `string` | Required in parent | What to draw, or how to change the images. |
| `n` | `integer` | Optional | How many images to make. |
| `size` | `string` | Optional | Exact pixels, such as `1024x1024`. `auto` sends none. |
| `aspect_ratio` | `string` | Optional | The shape alone, such as `16:9`. |
| `resolution` | `string` | Optional | The provider's named tier, such as `2K`. |
| `seed` | `integer` | Optional | A number that makes a draw repeat. |
| `negative_prompt` | `string` | Optional | What to leave out. |
| `output_format` | `string` | Optional | The file format of the images, such as `png`. |
| `quality` | `string` | Optional | OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it. |
| `background` | `string` | Optional | OpenAI's own field. MiniMax refuses `transparent` with `400`. |
| `response_format` | `string` | Optional | `b64_json` or `url`, as the provider takes it. Qwen answers URLs only. |
| `image` | `string` | Optional | The image to change, as a file.<br />Format: `binary` |
| `image[]` | `array<string>` | Optional | Several images to change, each as a file. Send this or `image`. |
| `image[][]` | `string` | Array item | Format: `binary` |
| `mask` | `string` | Optional | Where the image may change, as a file. Gemini, OpenRouter, MiniMax and EmpirioLabs drop it, Qwen refuses it with `400`, and Bedrock takes it for inpaint and erase only.<br />Format: `binary` |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "type": "object",
  "required": [
    "model",
    "prompt"
  ],
  "properties": {
    "model": {
      "type": "string",
      "description": "The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one."
    },
    "prompt": {
      "type": "string",
      "description": "What to draw, or how to change the images."
    },
    "n": {
      "type": "integer",
      "description": "How many images to make."
    },
    "size": {
      "type": "string",
      "description": "Exact pixels, such as `1024x1024`. `auto` sends none."
    },
    "aspect_ratio": {
      "type": "string",
      "description": "The shape alone, such as `16:9`."
    },
    "resolution": {
      "type": "string",
      "description": "The provider's named tier, such as `2K`."
    },
    "seed": {
      "type": "integer",
      "description": "A number that makes a draw repeat."
    },
    "negative_prompt": {
      "type": "string",
      "description": "What to leave out."
    },
    "output_format": {
      "type": "string",
      "description": "The file format of the images, such as `png`."
    },
    "quality": {
      "type": "string",
      "description": "OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it."
    },
    "background": {
      "type": "string",
      "description": "OpenAI's own field. MiniMax refuses `transparent` with `400`."
    },
    "response_format": {
      "type": "string",
      "description": "`b64_json` or `url`, as the provider takes it. Qwen answers URLs only."
    },
    "image": {
      "type": "string",
      "format": "binary",
      "description": "The image to change, as a file."
    },
    "image[]": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "binary"
      },
      "description": "Several images to change, each as a file. Send this or `image`."
    },
    "mask": {
      "type": "string",
      "description": "Where the image may change, as a file. Gemini, OpenRouter, MiniMax and EmpirioLabs drop it, Qwen refuses it with `400`, and Bedrock takes it for inpaint and erase only.",
      "format": "binary"
    }
  }
}
```

</details>

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | - |
| `model` | `string` | Required in parent | The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one. |
| `prompt` | `string` | Required in parent | What to draw, or how to change the images. |
| `n` | `integer` | Optional | How many images to make. |
| `size` | `string` | Optional | Exact pixels, such as `1024x1024`. `auto` sends none. |
| `aspect_ratio` | `string` | Optional | The shape alone, such as `16:9`. |
| `resolution` | `string` | Optional | The provider's named tier, such as `2K`. |
| `seed` | `integer` | Optional | A number that makes a draw repeat. |
| `negative_prompt` | `string` | Optional | What to leave out. |
| `output_format` | `string` | Optional | The file format of the images, such as `png`. |
| `quality` | `string` | Optional | OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it. |
| `background` | `string` | Optional | OpenAI's own field. MiniMax refuses `transparent` with `400`. |
| `response_format` | `string` | Optional | `b64_json` or `url`, as the provider takes it. Qwen answers URLs only. |
| `images` | `array<object>` | Required in parent | The images to change, each named by URL. A data URL carries a file's bytes; an image named by `file_id` is refused with `400`.<br />Minimum items: `1` |
| `images[]` | `object` | Array item | - |
| `images[].image_url` | `string` | Required in parent | An `https` URL or a data URL of the image. |
| `mask` | `object` | Optional | Where the image may change, named by URL. Gemini, OpenRouter, MiniMax and EmpirioLabs drop it, Qwen refuses it with `400`, and Bedrock takes it for inpaint and erase only. |
| `mask.image_url` | `string` | Required in parent | An `https` URL or a data URL of the mask. |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "type": "object",
  "required": [
    "model",
    "prompt",
    "images"
  ],
  "properties": {
    "model": {
      "type": "string",
      "description": "The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one."
    },
    "prompt": {
      "type": "string",
      "description": "What to draw, or how to change the images."
    },
    "n": {
      "type": "integer",
      "description": "How many images to make."
    },
    "size": {
      "type": "string",
      "description": "Exact pixels, such as `1024x1024`. `auto` sends none."
    },
    "aspect_ratio": {
      "type": "string",
      "description": "The shape alone, such as `16:9`."
    },
    "resolution": {
      "type": "string",
      "description": "The provider's named tier, such as `2K`."
    },
    "seed": {
      "type": "integer",
      "description": "A number that makes a draw repeat."
    },
    "negative_prompt": {
      "type": "string",
      "description": "What to leave out."
    },
    "output_format": {
      "type": "string",
      "description": "The file format of the images, such as `png`."
    },
    "quality": {
      "type": "string",
      "description": "OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it."
    },
    "background": {
      "type": "string",
      "description": "OpenAI's own field. MiniMax refuses `transparent` with `400`."
    },
    "response_format": {
      "type": "string",
      "description": "`b64_json` or `url`, as the provider takes it. Qwen answers URLs only."
    },
    "images": {
      "type": "array",
      "minItems": 1,
      "description": "The images to change, each named by URL. A data URL carries a file's bytes; an image named by `file_id` is refused with `400`.",
      "items": {
        "type": "object",
        "required": [
          "image_url"
        ],
        "properties": {
          "image_url": {
            "type": "string",
            "description": "An `https` URL or a data URL of the image."
          }
        }
      }
    },
    "mask": {
      "type": "object",
      "required": [
        "image_url"
      ],
      "description": "Where the image may change, named by URL. Gemini, OpenRouter, MiniMax and EmpirioLabs drop it, Qwen refuses it with `400`, and Bedrock takes it for inpaint and erase only.",
      "properties": {
        "image_url": {
          "type": "string",
          "description": "An `https` URL or a data URL of the mask."
        }
      }
    }
  }
}
```

</details>

## Responses

### 200

Images in OpenAI's Images shape. Each item of `data` holds a `b64_json` or a `url`, as the provider returns it.

#### Response headers


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| `X-Respan-Log-Id` | `string` | Optional | ID of the Respan request log for this call. |


#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |
| `created` | `integer` | Optional | - |
| `data` | `array<object>` | Optional | - |
| `data[]` | `object` | Array item | Additional properties are allowed |
| `data[].b64_json` | `string` | Optional | - |
| `data[].url` | `string` | Optional | - |
| `data[].revised_prompt` | `string` | Optional | - |
| `usage` | `object` | Optional | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "created": {
      "type": "integer"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "b64_json": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "revised_prompt": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "usage": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
```

</details>

### 400

The request is malformed, or a field is one the provider cannot take. Fields refused before the call say which one.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": true
}
```

</details>

### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 429

A rate limit or usage limit was reached. Retry with exponential backoff.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": true
}
```

</details>

## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Edit an image",
  "operationId": "createImageEdit",
  "tags": [
    "Gateway"
  ],
  "servers": [
    {
      "url": "https://gateway.respan.ai",
      "description": "Respan gateway"
    }
  ],
  "description": "Changes the images you send, guided by a prompt. Follows OpenAI's Images API. Send a multipart form, or JSON that names each image by URL. Served by Bedrock, Gemini, MiniMax, OpenAI, OpenRouter, Qwen, Together AI and xAI. Send Respan parameters of a multipart edit in the `X-Data-Respan-Params` header (base64 JSON).",
  "security": [
    {
      "RespanApiKey": []
    }
  ],
  "parameters": [
    {
      "name": "X-Data-Respan-Params",
      "in": "header",
      "required": false,
      "schema": {
        "type": "string"
      },
      "description": "Base64-encoded JSON object of Respan request parameters."
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "multipart/form-data": {
        "schema": {
          "type": "object",
          "required": [
            "model",
            "prompt"
          ],
          "properties": {
            "model": {
              "type": "string",
              "description": "The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one."
            },
            "prompt": {
              "type": "string",
              "description": "What to draw, or how to change the images."
            },
            "n": {
              "type": "integer",
              "description": "How many images to make."
            },
            "size": {
              "type": "string",
              "description": "Exact pixels, such as `1024x1024`. `auto` sends none."
            },
            "aspect_ratio": {
              "type": "string",
              "description": "The shape alone, such as `16:9`."
            },
            "resolution": {
              "type": "string",
              "description": "The provider's named tier, such as `2K`."
            },
            "seed": {
              "type": "integer",
              "description": "A number that makes a draw repeat."
            },
            "negative_prompt": {
              "type": "string",
              "description": "What to leave out."
            },
            "output_format": {
              "type": "string",
              "description": "The file format of the images, such as `png`."
            },
            "quality": {
              "type": "string",
              "description": "OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it."
            },
            "background": {
              "type": "string",
              "description": "OpenAI's own field. MiniMax refuses `transparent` with `400`."
            },
            "response_format": {
              "type": "string",
              "description": "`b64_json` or `url`, as the provider takes it. Qwen answers URLs only."
            },
            "image": {
              "type": "string",
              "format": "binary",
              "description": "The image to change, as a file."
            },
            "image[]": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "binary"
              },
              "description": "Several images to change, each as a file. Send this or `image`."
            },
            "mask": {
              "type": "string",
              "description": "Where the image may change, as a file. Gemini, OpenRouter, MiniMax and EmpirioLabs drop it, Qwen refuses it with `400`, and Bedrock takes it for inpaint and erase only.",
              "format": "binary"
            }
          }
        }
      },
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "model",
            "prompt",
            "images"
          ],
          "properties": {
            "model": {
              "type": "string",
              "description": "The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one."
            },
            "prompt": {
              "type": "string",
              "description": "What to draw, or how to change the images."
            },
            "n": {
              "type": "integer",
              "description": "How many images to make."
            },
            "size": {
              "type": "string",
              "description": "Exact pixels, such as `1024x1024`. `auto` sends none."
            },
            "aspect_ratio": {
              "type": "string",
              "description": "The shape alone, such as `16:9`."
            },
            "resolution": {
              "type": "string",
              "description": "The provider's named tier, such as `2K`."
            },
            "seed": {
              "type": "integer",
              "description": "A number that makes a draw repeat."
            },
            "negative_prompt": {
              "type": "string",
              "description": "What to leave out."
            },
            "output_format": {
              "type": "string",
              "description": "The file format of the images, such as `png`."
            },
            "quality": {
              "type": "string",
              "description": "OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it."
            },
            "background": {
              "type": "string",
              "description": "OpenAI's own field. MiniMax refuses `transparent` with `400`."
            },
            "response_format": {
              "type": "string",
              "description": "`b64_json` or `url`, as the provider takes it. Qwen answers URLs only."
            },
            "images": {
              "type": "array",
              "minItems": 1,
              "description": "The images to change, each named by URL. A data URL carries a file's bytes; an image named by `file_id` is refused with `400`.",
              "items": {
                "type": "object",
                "required": [
                  "image_url"
                ],
                "properties": {
                  "image_url": {
                    "type": "string",
                    "description": "An `https` URL or a data URL of the image."
                  }
                }
              }
            },
            "mask": {
              "type": "object",
              "required": [
                "image_url"
              ],
              "description": "Where the image may change, named by URL. Gemini, OpenRouter, MiniMax and EmpirioLabs drop it, Qwen refuses it with `400`, and Bedrock takes it for inpaint and erase only.",
              "properties": {
                "image_url": {
                  "type": "string",
                  "description": "An `https` URL or a data URL of the mask."
                }
              }
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Images in OpenAI's Images shape. Each item of `data` holds a `b64_json` or a `url`, as the provider returns it.",
      "headers": {
        "X-Respan-Log-Id": {
          "description": "ID of the Respan request log for this call.",
          "schema": {
            "type": "string"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "created": {
                "type": "integer"
              },
              "data": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "b64_json": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "revised_prompt": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "usage": {
                "type": "object",
                "additionalProperties": true
              }
            },
            "additionalProperties": true
          }
        }
      }
    },
    "400": {
      "description": "The request is malformed, or a field is one the provider cannot take. Fields refused before the call say which one.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "429": {
      "description": "A rate limit or usage limit was reached. Retry with exponential backoff.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    }
  }
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
