# SEE2AI 图像生成 · 稳定交付

> SEE2AI guaranteed image generation. Valid accepted jobs stay recoverable across provider interruptions and return SEE2AI-hosted images when ready.

## 📖 接入指引

**Endpoint**: `POST /api/v1/actions/see2ai_image_generation_guaranteed_v1`

**认证方式**: Bearer Token (租户 API Key)

### Endpoints

| Method | Path | Purpose |
| --- | --- | --- |
| `POST` | `/api/v1/actions/see2ai_image_generation_guaranteed_v1` | Submit the standard action request. |

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

## 📥 输入参数 (Input Schema)

```json
{
  "properties": {
    "prompt": {
      "description": "Target image description, up to 20,000 characters.",
      "maxLength": 20000,
      "title": "Prompt",
      "type": "string"
    },
    "input_urls": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "description": "Optional public reference image URLs.",
      "title": "Input Urls"
    },
    "image_input": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Compatibility alias for input_urls.",
      "title": "Image Input"
    },
    "aspect_ratio": {
      "default": "auto",
      "description": "Target image aspect ratio.",
      "enum": [
        "auto",
        "1:1",
        "9:16",
        "16:9",
        "4:3",
        "3:4"
      ],
      "title": "Aspect Ratio",
      "type": "string"
    },
    "resolution": {
      "default": "2K",
      "description": "Target output resolution.",
      "enum": [
        "1K",
        "2K",
        "4K"
      ],
      "title": "Resolution",
      "type": "string"
    },
    "idempotency_key": {
      "anyOf": [
        {
          "maxLength": 128,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Optional caller-supplied idempotency key for duplicate submit protection.",
      "title": "Idempotency Key"
    }
  },
  "required": [
    "prompt"
  ],
  "title": "ImageGenerationGuaranteedInput",
  "type": "object"
}
```

### 参数说明

| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|--------|------|------|--------|------|
| `prompt` | string | ✅ 是 | `-` | Target image description, up to 20,000 characters. |
| `input_urls` | array / null | ❌ 否 | `-` | Optional public reference image URLs. |
| `image_input` | array / null | ❌ 否 | `-` | Compatibility alias for input_urls. |
| `aspect_ratio` | string enum | ❌ 否 | `auto` | Target image aspect ratio. |
| `resolution` | string enum | ❌ 否 | `2K` | Target output resolution. |
| `idempotency_key` | string / null | ❌ 否 | `-` | Optional caller-supplied idempotency key for duplicate submit protection. |

## 📤 输出结果 (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": "SEE2AI task id used for status polling.",
      "title": "Task Id",
      "type": "string"
    },
    "status": {
      "description": "running | success | failed.",
      "title": "Status",
      "type": "string"
    },
    "result_urls": {
      "description": "SEE2AI-hosted image URLs, populated on terminal success.",
      "items": {
        "type": "string"
      },
      "title": "Result Urls",
      "type": "array"
    },
    "estimated_cost": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Estimated token cost at submit.",
      "title": "Estimated Cost"
    },
    "failure_kind": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Present only for user-actionable failures.",
      "title": "Failure Kind"
    },
    "error_code": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Brand-safe repair code when user action is required.",
      "title": "Error Code"
    },
    "message": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Brand-safe status or repair message.",
      "title": "Message"
    },
    "retry_after_seconds": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Suggested delay before the next poll.",
      "title": "Retry After Seconds"
    },
    "warnings": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Non-blocking optimization suggestions produced by pre-validation.",
      "title": "Warnings"
    }
  },
  "required": [
    "task_id",
    "status"
  ],
  "title": "ImageGenerationGuaranteedStatusOutput",
  "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 | SEE2AI task id used for status polling. |
| `status` | string | running | success | failed. |
| `result_urls` | array | SEE2AI-hosted image URLs, populated on terminal success. |
| `estimated_cost` | integer / null | Estimated token cost at submit. |
| `failure_kind` | string / null | Present only for user-actionable failures. |
| `error_code` | string / null | Brand-safe repair code when user action is required. |
| `message` | string / null | Brand-safe status or repair message. |
| `retry_after_seconds` | integer / null | Suggested delay before the next poll. |
| `warnings` | array / null | Non-blocking optimization suggestions produced by pre-validation. |

## 💡 调用示例

### cURL 示例

```bash
curl -X POST "https://see2ai.com/api/v1/actions/see2ai_image_generation_guaranteed_v1" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer sk-your-tenant-api-key" \
     -d '{
  "prompt": "Create a clean product visual with clear composition.",
  "aspect_ratio": "auto",
  "resolution": "2K"
}'
```

### Python 示例

```python
import requests

API_KEY = "sk-your-tenant-api-key"
ENDPOINT = "https://see2ai.com/api/v1/actions/see2ai_image_generation_guaranteed_v1"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_KEY}"
}

payload = {
  "prompt": "Create a clean product visual with clear composition.",
  "aspect_ratio": "auto",
  "resolution": "2K"
}

response = requests.post(ENDPOINT, json=payload, headers=headers)
result = response.json()

print(f"结果：{result}")
```

## 💰 计费说明

> Charge is applied once after a SEE2AI-hosted image result is ready.

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

## ⚠️ 常见错误码

| HTTP 状态码 | 错误原因 | 解决方案 |
| --- | --- | --- |
| `400` | Input validation failed before the job was accepted. | 请稍后重试 |
| `402` | Insufficient balance before accept or at terminal claim. | 请稍后重试 |
| `451` | Content review requires prompt or reference changes. | 请稍后重试 |
| `500` | Provider/system faults remain internal retry states after accept. | 稍后重试，如持续失败请联系技术支持 |

## 📞 技术支持

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

---

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