> ## 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.

# 编辑图像

> <ul><li>在给定原始图像和提示的情况下创建编辑或扩展图像。</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=一只小猫在阳光下的花园里奔跑，电影感，高细节' \
    --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": "一只小猫在阳光下的花园里奔跑，电影感，高细节",
      "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", "一只小猫在阳光下的花园里奔跑，电影感，高细节");
  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>
  所有接口均需要使用 Bearer Token 进行认证。

  在请求头中添加：

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

## Body

<ParamField body="image" type="file" required>
  要编辑的图像。必须是有效的 PNG 文件，小于 4MB，并且是方形的。如果未提供遮罩，图像必须具有透明度，将用作遮罩。

  示例：`cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.png`
</ParamField>

<ParamField body="mask" type="file">
  附加图像，其完全透明区域（例如，alpha 为零的区域）指示image应编辑的位置。必须是有效的 PNG 文件，小于 4MB，并且尺寸与原始image相同。

  示例：\`\`
</ParamField>

<ParamField body="prompt" type="string" required>
  所需图像的文本描述。最大长度为 1000 个字符。

  示例：`A cute baby sea otter wearing a beret.`
</ParamField>

<ParamField body="n" type="string">
  要生成的图像数。必须介于 1 和 10 之间。

  示例：`1`
</ParamField>

<ParamField body="size" type="string">
  生成图像的大小。必须是`256x256`、`512x512`或 `1024x1024`之一。

  示例：`1024x1024`
</ParamField>

<ParamField body="response_format" type="string">
  生成的图像返回的格式。必须是`url`或`b64_json`。

  示例：`url`
</ParamField>

<ParamField body="user" type="string">
  代表您的最终用户的唯一标识符，可以帮助 OpenAI 监控和检测滥用行为。[了解更多](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids)。

  示例：\`\`
</ParamField>

<ParamField body="model" type="string" default="gpt-image-1.5">
  示例：`gpt-image-1.5`
</ParamField>

## Response
