# SEE2AI 图片去背景

> Remove an image background and keep the foreground transparent around its edges.

## 📖 接入指引

**Endpoint**: `POST /api/platform/v1/actions/see2ai_image_background_remove_v1/async`

Send the Platform service token as Bearer auth and the acting user's token in `X-Platform-User-Token`.

### Endpoints

| Method | Path | Purpose |
| --- | --- | --- |
| `POST` | `/api/platform/v1/actions/see2ai_image_background_remove_v1/async` | Submit an image task. Use X-Idempotency-Key to replay the same request safely. |
| `GET` | `/api/platform/v1/actions/see2ai_image_background_remove_v1/status/{task_id}` | Poll for the result. On success, image_url points to the stored image. |

> **⚠️ 重要提示**
> 
> 本 API 是 SEE2AI 平台标准化封装后的接口，**参数格式与任何上游 API 不同**。
> 请直接使用下方 Schema 中定义的参数，无需参考其他文档。
> 
> *例如：*
> *- 文本模型参数可能是 `query` 而不是 `messages` 数组*
> *- 视频模型参数可能是 `brief` (创意简报) 而不是复杂的配置项*

## 📥 输入参数 (Input Schema)

```json
{
  "additionalProperties": false,
  "examples": [
    {
      "image_url": "https://cdn.example.com/image.png"
    }
  ],
  "properties": {
    "image_url": {
      "description": "Public HTTPS PNG, JPEG, WebP, TIFF, BMP, or HEIC image up to 30 MB and 40 megapixels. General accepts long edge ≤10240 px and short edge ≤6000 px. Human and product accept long edge ≤7680 px and short edge ≤4320 px.",
      "title": "Image Url",
      "type": "string"
    },
    "subject": {
      "default": "general",
      "description": "Type of foreground subject to retain.",
      "enum": [
        "general",
        "human",
        "product"
      ],
      "title": "Subject",
      "type": "string"
    }
  },
  "required": [
    "image_url"
  ],
  "title": "ActionInput",
  "type": "object"
}
```

### 参数说明

| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|--------|------|------|--------|------|
| `image_url` | string | ✅ 是 | `-` | Public HTTPS PNG, JPEG, WebP, TIFF, BMP, or HEIC image up to 30 MB and 40 megapixels. General accepts long edge ≤10240 px and short edge ≤6000 px. Human and product accept long edge ≤7680 px and short edge ≤4320 px. |
| `subject` | string enum | ❌ 否 | `general` | Type of foreground subject to retain. |

## 📤 输出结果 (Output Schema)

```json
{
  "properties": {
    "input_tokens": {
      "default": 0,
      "description": "输入消耗的词元数量",
      "title": "Input Tokens",
      "type": "integer"
    },
    "output_tokens": {
      "default": 0,
      "description": "输出消耗的词元数量",
      "title": "Output Tokens",
      "type": "integer"
    },
    "total_tokens": {
      "default": 0,
      "description": "总消耗的词元数量",
      "title": "Total Tokens",
      "type": "integer"
    },
    "model": {
      "default": "",
      "description": "实际使用的 SEE2AI 化身模型名称（由各 action 显式填写）",
      "title": "Model",
      "type": "string"
    },
    "source": {
      "default": "see2ai",
      "description": "服务来源（统一 `see2ai`；真实路由仅平台内部可见）",
      "title": "Source",
      "type": "string"
    },
    "cost_points": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "预先计算的扣费词元（如果插件内部已经计算好费用，则直接使用此值，忽略基于词元的计算）",
      "title": "Cost Points"
    },
    "task_id": {
      "description": "Opaque task ID used for status polling.",
      "title": "Task Id",
      "type": "string"
    },
    "status": {
      "description": "Normalized task status: running, success, or failed.",
      "enum": [
        "running",
        "success",
        "failed"
      ],
      "title": "Status",
      "type": "string"
    },
    "result_urls": {
      "description": "Durable result URLs, empty until success.",
      "items": {
        "type": "string"
      },
      "title": "Result Urls",
      "type": "array"
    },
    "estimated_cost": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Maximum platform points held until settlement.",
      "title": "Estimated Cost"
    },
    "retryable": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Whether a non-terminal status should be polled again.",
      "title": "Retryable"
    },
    "retry_after_seconds": {
      "anyOf": [
        {
          "minimum": 1,
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Suggested wait before the next poll.",
      "title": "Retry After Seconds"
    },
    "error_message": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Brand-safe failure or retry guidance.",
      "title": "Error Message"
    },
    "warnings": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Non-blocking optimization suggestions produced by validation.",
      "title": "Warnings"
    },
    "image_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Durable image URL after successful delivery.",
      "title": "Image Url"
    },
    "width": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Delivered width in pixels.",
      "title": "Width"
    },
    "height": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Delivered height in pixels.",
      "title": "Height"
    },
    "format": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Delivered file format, for example png or jpeg.",
      "title": "Format"
    },
    "subject": {
      "anyOf": [
        {
          "enum": [
            "general",
            "human",
            "product"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Requested foreground subject type.",
      "title": "Subject"
    }
  },
  "required": [
    "task_id",
    "status"
  ],
  "title": "ActionOutput",
  "type": "object"
}
```

### 输出字段说明

| 字段名 | 类型 | 说明 |
|--------|------|------|
| `input_tokens` | integer | 输入消耗的词元数量 |
| `output_tokens` | integer | 输出消耗的词元数量 |
| `total_tokens` | integer | 总消耗的词元数量 |
| `model` | string | 实际使用的 SEE2AI 化身模型名称（由各 action 显式填写） |
| `source` | string | 服务来源（统一 `see2ai`；真实路由仅平台内部可见） |
| `cost_points` | integer / null | 预先计算的扣费词元（如果插件内部已经计算好费用，则直接使用此值，忽略基于词元的计算） |
| `task_id` | string | Opaque task ID used for status polling. |
| `status` | string enum | Normalized task status: running, success, or failed. |
| `result_urls` | array | Durable result URLs, empty until success. |
| `estimated_cost` | integer / null | Maximum platform points held until settlement. |
| `retryable` | boolean / null | Whether a non-terminal status should be polled again. |
| `retry_after_seconds` | integer / null | Suggested wait before the next poll. |
| `error_message` | string / null | Brand-safe failure or retry guidance. |
| `warnings` | array / null | Non-blocking optimization suggestions produced by validation. |
| `image_url` | string / null | Durable image URL after successful delivery. |
| `width` | integer / null | Delivered width in pixels. |
| `height` | integer / null | Delivered height in pixels. |
| `format` | string / null | Delivered file format, for example png or jpeg. |
| `subject` | string enum / null | Requested foreground subject type. |

## 💡 调用示例

### Submit with cURL

Keep one `X-Idempotency-Key` per logical request. Reuse it with the same body to recover the first task.

```bash
curl -X POST "https://see2ai.com/api/platform/v1/actions/see2ai_image_background_remove_v1/async" \
     -H "Authorization: Bearer $SERVICE_TOKEN" \
     -H "X-Platform-User-Token: $USER_TOKEN" \
     -H "Content-Type: application/json" \
     -H "X-Idempotency-Key: image-edit-001" \
     -d '{
  "image_url": "https://cdn.example.com/image.png"
}'
```

### Poll with cURL

Set `TASK_ID` to the returned `task_id`. Poll until `success` or `failed`. A retryable failure can be submitted again with a new key.

```bash
curl "https://see2ai.com/api/platform/v1/actions/see2ai_image_background_remove_v1/status/$TASK_ID" \
     -H "Authorization: Bearer $SERVICE_TOKEN" \
     -H "X-Platform-User-Token: $USER_TOKEN"
```

## 💰 计费说明

> 500 points per delivered image.

**注意**: 所有费用都以词元为单位，系统会自动从租户余额中扣除。

## ⚠️ 常见错误码

| HTTP 状态码 | 错误原因 | 解决方案 |
| --- | --- | --- |
| `400` | The image or parameters violate an action limit. | 请稍后重试 |
| `402` | Insufficient points to reserve the image charge. | 请稍后重试 |
| `404` | No task exists for this caller and task ID. | 请稍后重试 |
| `409` | The idempotency key is already bound to a different request. | 请稍后重试 |
| `422` | Invalid request shape, enum, or image request. | 检查请求参数是否符合 Schema 要求 |
| `503` | Image service or settlement is temporarily unavailable. | 请稍后重试 |

## 📞 技术支持

- **文档问题**: 查看 [SEE2AI 官方文档](https://see2ai.com/docs)
- **API 状态**: 访问 [服务状态页面](https://see2ai.com/status)
- **问题反馈**: 联系技术支持团队

---

**API 版本**: see2ai_image_background_remove_v1
**最后更新**: 2026-03-23
