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

# Ming Image Layer Decoupling

`ming-image-0.1-design-layer` only supports layer decoupling, using the OpenAI Image edits protocol.

## Request Headers

<ParamField header="Content-Type" type="string" required={true}>
  Supports: `multipart/form-data`
</ParamField>

<ParamField header="Authorization" type="string" required={true}>
  Bearer authentication format, for example: Bearer \{\{API Key}}.
</ParamField>

## Request Body

<ParamField body="model" type="enum" required={true}>
  The model name. Available values: `ming-image-0.1-design-layer`
</ParamField>

<ParamField body="image" type="Files" required={true}>
  The input image, 1 image. It is `image[]` in the form.

  `ming-image-0.1-design-layer` only supports 1 image input.
</ParamField>

<ParamField body="prompt" type="string" required={true}>
  The text description of the image.
</ParamField>

<ParamField body="output_format" type="string" default="png" required={false}>
  The output image format. Must be one of `png` or `webp`.
</ParamField>

<ParamField body="response_format" type="string" default="b64_json" required={false}>
  The form in which the image is returned, default is `b64_json`. Available values: `url`, `b64_json`. Note: `url` is valid for 24 hours.
</ParamField>

<ParamField body="size" type="string" default="auto" required={false}>
  The output image size, default `auto` selects automatically based on the model. Format `"{w}x{h}"`, e.g. `"1024x1024"`.
</ParamField>

<ParamField body="watermark" type="boolean" default={false} required={false}>
  Controls whether a watermark is added to the AI-generated image. `true`: enables the explicit watermark and implicit digital watermark on AI-generated images, complying with policy requirements. `false`: disables all watermarks.
</ParamField>

## Response

<ResponseField name="created" type="integer" required={true}>
  The Unix timestamp (seconds) when the response was created.
</ResponseField>

<ResponseField name="data" type="array" required={true}>
  The array of returned images, containing multiple layers (e.g. foreground layer, background layer, etc.), one element per layer.

  <Expandable title="properties">
    <ResponseField name="b64_json" type="string">
      The base64-encoded layer image data.
    </ResponseField>

    <ResponseField name="data[0].revised_prompt" type="string">
      A JSON string describing the layer structure, indicating the canvas size and the information of each region.

      <Expandable title="properties">
        <ResponseField name="revised_prompt.canvas" type="array">
          The canvas size `[width, height]`.
        </ResponseField>

        <ResponseField name="revised_prompt.regions" type="array">
          The list of layer regions.

          <Expandable title="properties">
            <ResponseField name="revised_prompt.regions[].category" type="string">
              The layer category, e.g. `Image` (foreground layer), `BackgroundImage` (background layer).
            </ResponseField>

            <ResponseField name="revised_prompt.regions[].bbox" type="array">
              The bounding box of the layer on the canvas `[x1, y1, x2, y2]`.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="output_format" type="string" required={true}>
  The output image format (layers are always output as png).
</ResponseField>

<ResponseField name="size" type="string">
  `null`
</ResponseField>

<ResponseField name="usage" type="object" required={true}>
  Token usage statistics.

  <Expandable title="properties">
    <ResponseField name="input_tokens" type="integer">
      Total input tokens (including the tokens of the uploaded image).
    </ResponseField>

    <ResponseField name="input_tokens_details" type="object">
      Input token details.

      <Expandable title="properties">
        <ResponseField name="image_tokens" type="integer">
          The number of tokens consumed by the input image.
        </ResponseField>

        <ResponseField name="text_tokens" type="integer">
          The number of tokens consumed by the input text.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="output_tokens" type="integer">
      Total output tokens (the sum across multiple layers, e.g. 3 layers × 4096 = 12288).
    </ResponseField>

    <ResponseField name="total_tokens" type="integer">
      The total of input + output tokens.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="model" type="string" required={true}>
  The name of the model that actually processed the request.
</ResponseField>

<ResponseField name="id" type="string" required={true}>
  The unique identifier ID of this request.
</ResponseField>

## Example

`Request:`

```bash theme={"system"}
curl --location --request POST 'https://api.novita.ai/v1/images/edits' \
--header 'Authorization: Bearer {{API Key}}' \
--form 'model="ming-image-0.1-design-layer"' \
--form 'prompt="Split into three layers"' \
--form 'image[]=@"{The Path of Your Image File}"' \
--form 'size="1024x1024"'
```

`Response:`

```js theme={"system"}
{
  "created": 1789642431,
  "data": [
    {
      "b64_json": "...",
      "revised_prompt": "{\"canvas\": [1024, 1024], \"regions\": [{\"category\": \"Image\", \"bbox\": [1.4, 3.3, 1023.0, 1022.0]}, {\"category\": \"BackgroundImage\", \"bbox\": [1.4, 3.3, 1023.0, 1022.0]}]}"
    },
    {
      "b64_json": "..."
    },
    {
      "b64_json": "..."
    }
  ],
  "output_format": "png",
  "size": null,
  "usage": {
    "input_tokens": 4096,
    "input_tokens_details": {
      "image_tokens": 4096,
      "text_tokens": 0
    },
    "output_tokens": 12288,
    "total_tokens": 16384
  },
  "model": "Ming-Image-0.1-Design-Layer-StressTest",
  "id": "218edba617896423893976485e4f35"
}
```
