# Pixelcut Product Photo API

> 商品图合成器：抠出商品并将其放置在带背景、边距和阴影的新画布上

将商品照片处理为目录风格的图像。可使用 `image_size` 预设或自定义尺寸设置画布，选择纯色、透明或图像 `background`，并调整 `margin`。可添加生成式阴影或投影 `shadow`，以及可选的 `watermark` 叠加层。输出格式为 png 或 jpeg，且 jpeg 不能与透明背景一起使用。

- Model id: `pixelcut/product-photo`
- Made by: Pixelcut
- Category: Image Editing
- Output: image
- Price: $0.024 / image (cheapest run $0.024 (24 API credits))
- Run: `POST https://api.doitong.com/v1/run/pixelcut/product-photo`
- Quote: `POST https://api.doitong.com/v1/quote/pixelcut/product-photo`
- Docs page: https://doitong.com/zh/developers/models/pixelcut/product-photo

## Pricing

Price: **$0.024 / image**. Billed per generated image.

The full example input below costs $0.024 = 24 API credits (1 image × 24 API credits).

Prices are the upstream price in USD, paid from the API balance in API credits (1000 API credits = 1 USD). `POST https://api.doitong.com/v1/quote/pixelcut/product-photo` with the same JSON body returns the exact price for that input; the quote is exactly what a run charges. Invalid input is never charged and failed or canceled requests are refunded automatically.

## Input parameters

Send either the canonical name or the native field name (not both). Canonical names are the same across models.

| Parameter | Canonical name | Type | Required | Default | Allowed values / range | Description |
|---|---|---|---|---|---|---|
| `image_url` | `image` | string (image URL) | yes |  |  | 用于处理的产品图像 URL。 |
| `image_size` |  | object {width, height} \| enum (string) \| null | no | `square_hd` | `square_hd`, `square`, `portrait_4_3`, `portrait_16_9`, `landscape_4_3`, `landscape_16_9` | 输出画布尺寸，可指定为自定义 {width, height} 或预设值：square_hd、square、portrait_4_3、portrait_16_9、landscape_4_3、landscape_16_9。默认值为 square_hd (1024x1024)。 |
| `background` |  | object {mode, color, image_url, image_fit} | no |  |  | 输出背景：图像、透明背景或默认为白色的纯色。 |
| `background.mode` |  | enum (string) | no | `Color` | `Transparent`, `Color`, `Image` | 背景模式：'Color' 使用 `color`，默认值为白色；'Transparent' 生成透明背景并始终使用 PNG；'Image' 将结果合成到 `image_url` 上。 |
| `background.color` |  | object {r, g, b} | no | `{"b":255,"g":255,"r":255}` |  | 'Color' 模式的纯色背景填充，默认为白色，通过范围为 0 到 255 的 R/G/B 分量指定。 |
| `background.color.r` |  | integer | yes |  | 0 – 255 |  |
| `background.color.g` |  | integer | yes |  | 0 – 255 |  |
| `background.color.b` |  | integer | yes |  | 0 – 255 |  |
| `background.image_url` |  | string (image URL) \| null | no |  |  | 背景图像的 URL；在 'Image' 模式下必填。 |
| `background.image_fit` |  | enum (string) | no | `Cover` | `Cover`, `Contain`, `Stretch` | 选择背景图像适配画布的方式。'Contain' 保留适配后的图像，并在 `color` 上添加留白；'Stretch' 通过变形适配；'Cover' 通过裁剪填充画布。 |
| `margin` |  | object {all, left, right, top, bottom} | no |  |  | 产品与画布边缘之间的间距。使用 `all` 设置所有边距，也可单独覆盖各边；默认每边为 20%。 |
| `margin.all` |  | string | no | `20%` |  | 四边统一边距，以画布尺寸的 '%' 表示，范围为 0 到 49%，或以 'px' 表示，最小值为 0px。 |
| `margin.left` |  | string \| null | no |  |  | 替代该侧 `all` 值的左边距。接受 0 到 49% 的 '%'，或不低于 0px 的 'px'。 |
| `margin.right` |  | string \| null | no |  |  | 替代该侧 `all` 值的右边距。接受 0 到 49% 的 '%'，或不低于 0px 的 'px'。 |
| `margin.top` |  | string \| null | no |  |  | 替代该侧 `all` 值的上边距。接受 0 到 49% 的 '%'，或不低于 0px 的 'px'。 |
| `margin.bottom` |  | string \| null | no |  |  | 替代该侧 `all` 值的下边距。接受 0 到 49% 的 '%'，或不低于 0px 的 'px'。 |
| `shadow` |  | object {type, generative, drop} | no |  |  | 阴影配置：选择 'Generative' 或 'Drop' 并配置其设置。不设置则不应用阴影。 |
| `shadow.type` |  | enum (string) \| null | no |  | `Generative`, `Drop` | 可选阴影样式；未设置时不使用阴影。选择 'Generative' 进行 AI 合成，或选择 'Drop' 使用确定性投影阴影。 |
| `shadow.generative` |  | object {opacity, light_source} | no |  |  | AI 生成阴影的设置，在类型为 'Generative' 时应用。 |
| `shadow.generative.opacity` |  | number | no | `0.2` | 0 – 1 | 完全合成后阴影的不透明度，范围为 0 到 1。 |
| `shadow.generative.light_source` |  | object {size, position} \| null | no |  |  | 用于合成阴影的明确虚拟光源；提供后会替代根据图像自动估计的光照方向。 |
| `shadow.drop` |  | object {color, horizontal, vertical, blur, opacity} | no |  |  | 投影阴影的设置，在类型为 'Drop' 时应用。 |
| `shadow.drop.color` |  | object {r, g, b} | no | `{"b":0,"g":0,"r":0}` |  | 阴影的 RGB 颜色；默认为黑色。 |
| `shadow.drop.horizontal` |  | number | no | `50` | -100 – 100 | 水平阴影位移，最大设置值 100 表示画布宽度的 10%。取值范围为 -100 到 100；负值向左移动，正值向右移动。 |
| `shadow.drop.vertical` |  | number | no | `8` | -100 – 100 | 垂直阴影位移，最大设置值 100 表示画布高度的 10%。取值范围为 -100 到 100；负值向上移动，正值向下移动。 |
| `shadow.drop.blur` |  | number | no | `24` | 0 – 100 | 阴影模糊设置；100 时的最大柔化程度对应画布较短边的 5% 半径。范围从 0 开始，0 会保留硬边。 |
| `shadow.drop.opacity` |  | number | no | `0.25` | 0 – 1 | 阴影不透明度，范围为 0 到 1。 |
| `watermark` |  | object {image_url, remove_background, position, scale, opacity, margin} \| null | no |  |  | 通过提供图像启用徽标或水印叠加；省略时输出不会添加水印，这是默认行为。 |
| `watermark.image_url` |  | string (image URL) \| null | no |  |  | 徽标或水印图像的 URL。空值会使输出不带水印。 |
| `watermark.remove_background` |  | boolean | no | `false` |  | 是否使用背景移除功能去除水印背景，使叠加层不包含背景。 |
| `watermark.position` |  | enum (string) | no | `bottom_right` | `top_left`, `top_right`, `bottom_left`, `bottom_right`, `center` | 水印的位置。 |
| `watermark.scale` |  | number | no | `0.1` | 0.01 – 1 | 水印宽度，以画布宽度的比例表示。 |
| `watermark.opacity` |  | number | no | `1` | 0 – 1 | 水印不透明度，范围为 0 到 1。 |
| `watermark.margin` |  | string | no | `3%` |  | 距离画布边缘向内的距离，以画布的 '%' 表示（0–49%），或以 'px' 表示。 |
| `output_format` |  | enum (string) \| null | no |  | `png`, `jpeg` | 输出图像编码，可从 PNG 或 JPEG 中选择；透明背景不支持 JPEG。省略选择时将保留输入的格式。 |

File parameters (`image`) take a public `https://` URL, a `data:` URI up to 10 MB, or the `file_url` of an upload from `POST /files`.

## Example input

Required parameters only:

```json
{
  "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}
```

A fuller example:

```json
{
  "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}
```

## Run it

Set `DOITONG_API_KEY` to a key from https://doitong.com/developers/dashboard#keys. `?wait=20` returns the finished request in the same call when it is ready within 20 seconds; otherwise poll `GET /requests/{id}` (it also accepts `?wait=`), or pass `webhook_url`.

### curl

```bash
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/pixelcut/product-photo?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```

### JavaScript

```javascript
const API = "https://api.doitong.com/v1";
const headers = {
  "Authorization": "Bearer " + process.env.DOITONG_API_KEY,
  "Content-Type": "application/json",
};

// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/pixelcut/product-photo?wait=20", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);

// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
  res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
  request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
```

### Python

```python
import os
import requests

API = "https://api.doitong.com/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}

payload = {
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg",
}

# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/pixelcut/product-photo", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
    raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])

# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
    request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
    raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
```

### MCP

The MCP server at `https://api.doitong.com/v1/mcp` exposes the tools `search_models`, `get_model`, `quote`, `run`, `get_request`, `cancel_request`, `list_requests`, `create_upload` and `get_account`. A `run` call for this model:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "run",
    "arguments": {
      "model_id": "pixelcut/product-photo",
      "input": {
        "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
      },
      "wait_seconds": 20
    }
  }
}
```

## Response

Every call returns a request object. `status` is one of `queued`, `running`, `succeeded`, `failed`, `canceled`. `outputs` lists the generated files with URLs on our storage (kept forever, or 7 days with `?storage=temporary`; `storage` says which); `output` is the model's own result object with the same URLs.

```json
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "pixelcut/product-photo",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 24,
    "usd": "0.024",
    "charged": 24,
    "refunded": 0
  },
  "input": {
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  },
  "output": {
    "image": {
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_name": "0-output.jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768
    }
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
```

### Output fields (`output`)

| Field | Type | Description |
|---|---|---|
| `image` | object {url, content_type, file_name, file_size, width, height} \| null | 为目录使用准备的产品照片。 |

## Related models

- [Pixelcut Looping Video](https://doitong.com/developers/models/pixelcut/looping-video.md) (`pixelcut/looping-video`): from $0.08 / second
- [Pixelcut Background Remover](https://doitong.com/developers/models/pixelcut/background-removal.md) (`pixelcut/background-removal`): $0.016 / image
- [Pixelcut Video Background Removal](https://doitong.com/developers/models/pixelcut/video-background-removal.md) (`pixelcut/video-background-removal`): $0.022 / 30 frames of input video
- [FLUX.1 Kontext \[pro\]](https://doitong.com/developers/models/flux-pro/kontext.md) (`flux-pro/kontext`): $0.04 / image
- [GPT Image 2.5 Edit](https://doitong.com/developers/models/openai/gpt-image-2.5/flare/edit.md) (`openai/gpt-image-2.5/flare/edit`): from $0.12 / image
- [Nano Banana 2 Edit](https://doitong.com/developers/models/nano-banana-2/edit.md) (`nano-banana-2/edit`): from $0.06 / image
- [Nano Banana Pro Edit](https://doitong.com/developers/models/nano-banana-pro/edit.md) (`nano-banana-pro/edit`): from $0.15 / image
- [Qwen Image 3 Edit](https://doitong.com/developers/models/alibaba/qwen-image-3/edit.md) (`alibaba/qwen-image-3/edit`): from $0.04 / image

## Links

- HTML page: https://doitong.com/developers/models/pixelcut/product-photo
- All models and guides for AI agents: https://doitong.com/developers/llms.txt
- OpenAPI 3.1 with this model's typed request body: https://doitong.com/developers/openapi.json?model=pixelcut/product-photo
- Errors: https://doitong.com/developers/docs/errors
- Model details as JSON: https://api.doitong.com/v1/models/pixelcut/product-photo
