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

# Edit Image

> <ul><li>Create an edited or extended image from a source image and prompt.</li></ul>

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request POST \
    --url 'https://api.elkapi.com/v1/images/edits' \
    --header 'Authorization: Bearer <token>' \
    --form 'image=@https://example.com/image.png' \
    --form 'mask=@file.bin' \
    --form 'prompt=A small kitten running through a sunny garden, cinematic, highly detailed' \
    --form 'n=1' \
    --form 'size=1024x1024' \
    --form 'response_format=json' \
    --form 'user=' \
    --form 'model=gpt-image-1.5'
  ```

  ```python Python theme={null} theme={null}
  import requests

  url = "https://api.elkapi.com/v1/images/edits"
  headers = {
      "Authorization": "Bearer <token>"
  }
  files = {
      "image": open("https://example.com/image.png", "rb"),
      "mask": open("file.bin", "rb"),
  }
  data = {
      "prompt": "A small kitten running through a sunny garden, cinematic, highly detailed",
      "n": "1",
      "size": "1024x1024",
      "response_format": "json",
      "user": "",
      "model": "gpt-image-1.5",
  }

  response = requests.request("POST", url, headers=headers, data=data, files=files)
  print(response.text)
  ```

  ```javascript JavaScript theme={null} theme={null}
  const url = "https://api.elkapi.com/v1/images/edits";

  const headers = {
    "Authorization": "Bearer <token>"
  };
  const form = new FormData();
  form.append("image", fileInput.files[0]);
  form.append("mask", fileInput.files[0]);
  form.append("prompt", "A small kitten running through a sunny garden, cinematic, highly detailed");
  form.append("n", "1");
  form.append("size", "1024x1024");
  form.append("response_format", "json");
  form.append("user", "");
  form.append("model", "gpt-image-1.5");

  const response = await fetch(url, {
    method: "POST",
    headers,
    body: form
  });

  console.log(await response.text());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null} theme={null}
  {}
  ```
</ResponseExample>

## Authorizations

<ParamField header="Authorization" type="string" required>
  All endpoints require Bearer Token authentication.

  Add it to the request headers:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="image" type="file" required>
  Image to edit. Must be a valid PNG file, under 4 MB, and square. If no mask is provided, the image must include transparency, which will be used as the mask.

  Example: `cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.png`
</ParamField>

<ParamField body="mask" type="file">
  Additional image whose fully transparent areas (for example, areas with alpha zero) indicate where the image should be edited. Must be a valid PNG file, under 4 MB, and the same dimensions as the original image.

  Example: \`\`
</ParamField>

<ParamField body="prompt" type="string" required>
  Text description of the desired image. Maximum length: 1000 characters.

  Example: `A cute baby sea otter wearing a beret.`
</ParamField>

<ParamField body="n" type="string">
  Number of images to generate. Must be between 1 and 10.

  Example: `1`
</ParamField>

<ParamField body="size" type="string">
  Size of the generated image. Must be one of `256x256`, `512x512`, or `1024x1024`.

  Example: `1024x1024`
</ParamField>

<ParamField body="response_format" type="string">
  Format returned for the generated image. Must be `url` or `b64_json`.

  Example: `url`
</ParamField>

<ParamField body="user" type="string">
  A unique identifier for 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).

  Example: \`\`
</ParamField>

<ParamField body="model" type="string" default="gpt-image-1.5">
  Example: `gpt-image-1.5`
</ParamField>

## Response
