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

# Jimeng Image Editing

> Use `POST /v1/images/edits` to generate a new image by editing based on a reference image.

# Jimeng Image Editing

An OpenAI-compatible image editing interface, submitted using `multipart/form-data`, supports generating new images based on a reference image.

* The route entry is `POST /v1/images/edits`.
* Currently submitted using `multipart/form-data`.
* A reference image file must be provided for editing.
* Supports Jimeng model image editing capabilities.

## Supported Models

* `jimeng-4.0`: Jimeng 4.0 model
* `jimeng-4.5`: Jimeng 4.5 model

## Method and Path

```http theme={null}
POST /v1/images/edits
```

## Request Example

<CodeGroup>
  ```bash theme={null}
  curl -X POST https://octopusx.ai/v1/images/edits \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "model=jimeng-4.0" \
    -F "prompt=Generate a photorealistic image based on the reference image" \
    -F "image=@/path/to/image.png" \
    -F "n=1" \
    -F "ratio=16:9"
  ```

  ```python theme={null}
  import requests

  with open("image.png", "rb") as f:
      resp = requests.post(
          "https://octopusx.ai/v1/images/edits",
          headers={"Authorization": "Bearer YOUR_API_KEY"},
          data={
              "model": "jimeng-4.0",
              "prompt": "Generate a photorealistic image based on the reference image",
              "n": 1,
              "ratio": "16:9",
          },
          files={"image": f},
          timeout=60,
      )
      print(resp.json())
  ```
</CodeGroup>

## Response Example

<ResponseExample>
  ```json 200 theme={null}
  {
    "created": 1735689600,
    "data": [
      {
        "url": "https://example.com/edited-image.png",
        "revised_prompt": "Generate a photorealistic image based on the reference image"
      }
    ]
  }
  ```
</ResponseExample>

## Authentication

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Body

<ParamField body="model" type="string">
  Model name. For example, `jimeng-4.0`, `jimeng-4.5`.
</ParamField>

<ParamField body="prompt" type="string" required>
  Prompt. Text describing the editing content, supports Chinese and English.
</ParamField>

<ParamField body="image" type="file" required>
  The image to edit. Upload a single image file for editing. It must be a supported image file, supporting png, webp, and jpg formats, with each image no larger than 25MB.
</ParamField>

<ParamField body="n" type="integer">
  Number of images. The number of images to generate, defaults to 1.
</ParamField>

<ParamField body="ratio" type="string">
  Aspect ratio of the generated image. For example, `16:9`, `1:1`, `9:16`, etc.
</ParamField>

<ParamField body="quality" type="string">
  Quality of the generated image. `auto` (default) will automatically select the best quality for the given model. `gpt-image-l` supports `high`, `medium`, and `low`; `dall-e-3` supports `hd` and `standard`; `dall-e-2` supports only `standard`.
</ParamField>

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

<ParamField body="resolution" type="string">
  Resolution. Optional values: `1k`, `2k`, `4k`.
</ParamField>

## Response

<ResponseField name="created" type="integer">
  Generation timestamp (Unix timestamp).
</ResponseField>

<ResponseField name="data" type="array">
  Array of generation results.
</ResponseField>

<ResponseField name="data[].url" type="string">
  URL of the generated image.
</ResponseField>

<ResponseField name="data[].revised_prompt" type="string">
  Rewritten prompt (returned by some upstream services).
</ResponseField>

## Related APIs

* [Jimeng Image Overview](./overview)
* [Image Generation](./generation)
* [Official Format Image Generation](./official-generation)
* [Official Format Query](./official-query)
