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

# Image Edits

> Creates an edited or extended image given an original image and a prompt. Native OpenAI format.

## Headers

**Authorization** `string` *required*

Bearer token authentication. Format: `Bearer <token>`

## Body

Format: `multipart/form-data`

**image** `file` *required*

The image to edit. Must be a valid PNG file, less than 4MB, and square. If no mask is provided, the image must have transparency, which will be used as the mask.

Format: `binary`

**mask** `file`

An additional image whose fully transparent areas (e.g., where alpha is zero) indicate where the `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as the original `image`.

Format: `binary`

**prompt** `string` *required*

A text description of the desired image. Maximum length is 1,000 characters.

**n** `string`

The number of images to generate. Must be between 1 and 10.

**size** `string`

The size of the generated image. Must be one of `256x256`, `512x512`, or `1024x1024`.

**response\_format** `string`

The format in which the generated images are returned. Must be `url` or `b64_json`.

**user** `string`

A unique identifier representing your end user, which can help OpenAI monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

**model** `string`

Model ID.

## Response

### 200

Format: `application/json`

**created** `integer`

Creation timestamp (Unix time).

**data** `object[]`

List of edited images.

**Properties**

**b64\_json** `string`

Base64-encoded image data.

**url** `string`

Image URL.

```bash cURL theme={"dark"}
curl -X POST "https://t.ato2.nodesms.com/v1/images/edits/" \
  -H "Authorization: Bearer $API_KEY" \
  -F image="@otter.png" \
  -F mask="@mask.png" \
  -F prompt="A cute baby sea otter wearing a beret"
```

```python Python theme={"dark"}
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxx",
    base_url="https://t.ato2.nodesms.com/v1"
)

response = client.images.edit(
    model="dall-e-2",
    image=open("otter.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="A cute baby sea otter wearing a beret",
    n=1,
    size="1024x1024"
)
print(response.data[0].url)
```

```json 200 theme={"dark"}
{
  "created": 1719123456,
  "data": [
    {
      "url": "https://example.com/edited_image.png"
    }
  ]
}
```


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