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

# 商品营销图片 API

## 接入前准备

先登录 LuluLab，在「我的 Key」获取 luk- 开头的 API Key，并在自己的服务端保存。所有示例都向 [https://customer.lululab.ai](https://customer.lululab.ai) 发起请求；Authorization 请求头直接填写原始 Key。 [获取 API Key](https://www.lululab.ai/keys)

生成任务是异步的：POST /tasks 返回任务 id，随后调用 GET /tasks/\{id} 获取状态与 output。可以先通过 POST /billing/estimates 预估积分。

同样分两步：ProductImagePromptV1 根据商品图和事实生成图片方案。成功后从返回的 output 读取 imagePrompts.cards（部分结果会多包一层 output）；每张卡片包含 prompt、标题和叠字建议。再逐张提交 ImageGenV2 生图。

适合制作电商详情图、社交媒体商品卡片和多张连续的营销图片。上传清晰商品图，再提供产品名称、真实卖点、目标国家与受众；策划结果是文字方案，需要第二步才能得到图片。

### 第 1 步请求字段与枚举

| 字段 / 类型 | 必填 | 可选值与说明 |
| - | - | - |
| `input.productBrief.productName` (`string`) | 是 | 商品名称。 |
| `input.productBrief.sellingPoints` (`string[]`) | 是 | 真实卖点数组，例如 \["手工釉面"]。 |
| `input.productBrief.targetCountry` (`string`) | 是 | 目标国家或地区。 |
| `input.productBrief.targetAudience` (`string`) | 否 | 目标受众。 |
| `input.productBrief.productImages` (`array<MediaReference>`) | 是 | 至少一张商品图；url 使用上传返回的 location。 |
| `input.creativeRequirement` (`string`) | 否 | 补充创作要求。 |
| `input.userConfig.creativeMode` (`string`) | 是 | original · 首批方案固定为原创模式。 |
| `input.userConfig.cardsPerSet` (`integer`) | 是 | 1–10 · 本组营销图片数量。 |
| `input.userConfig.aspectRatio` (`string`) | 是 | 9:16 · 3:4 · 4:5 · 1:1 · 16:9 · 图片方案的目标比例。 |
| `input.userConfig.targetLanguage` (`string`) | 是 | 文案目标语言，例如 en-US。 |
| `input.userConfig.storyStyle` (`string`) | 是 | storyDrivenCarousel · 当前图片方案使用的连续叙事结构。 |
| `input.userConfig.imageStyle` (`string`) | 是 | storyDrivenCarousel · 当前图片方案使用的画面结构。 |
| `input.creatorBrief.creatorMode` (`string`) | 是 | none · provided · none 表示无出镜人物；provided 表示提供人物参考图。 |
| `input.creatorBrief.creatorImages` (`array<MediaReference>`) | 否 | 人物参考图；仅在 creatorMode 为 provided 时填写。 |

### 第 1 步：生成图片方案

```bash 商品图片策划请求 theme={null}
curl -X POST https://customer.lululab.ai/tasks \
  -H "Authorization: $LULULAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workflowId": "ProductImagePromptV1",
    "input": {
      "productBrief": {
        "productName": "Ceramic cup",
        "sellingPoints": ["Handmade finish"],
        "targetCountry": "United States",
        "targetAudience": "Coffee lovers",
        "productImages": [{ "url": "PRODUCT_IMAGE_URL", "mimeType": "image/jpeg" }]
      },
      "creativeRequirement": "Use only verified product facts.",
      "userConfig": {
        "creativeMode": "original",
        "cardsPerSet": 3,
        "aspectRatio": "9:16",
        "targetLanguage": "en-US",
        "storyStyle": "storyDrivenCarousel",
        "imageStyle": "storyDrivenCarousel"
      },
      "creatorBrief": { "creatorMode": "none", "creatorImages": [] }
    }
  }'
```

策划成功后从 output.imagePrompts.cards 读取卡片；每项有 prompt、title 和 textOverlay。若多包一层 output，先进入内层。

```json 图片方案响应示例（仅展示关键字段） theme={null}
{
  "status": "Succeeded",
  "output": {
    "imagePrompts": {
      "cards": [{
        "title": "Product hero",
        "prompt": "ONE_CARD_IMAGE_PROMPT",
        "textOverlay": "Handmade finish"
      }]
    }
  }
}
```

### 第 2 步请求字段

每张卡片用 ImageGenV2 单独生成；input.prompt 填对应卡片的 prompt，其余字段与图片生成 API 相同。

| 字段 / 类型 | 必填 | 可选值与说明 |
| - | - | - |
| `input.model` (`string`) | 是 | gpt-image-2-5-sunburst · gpt-image-2-5-flare · 图片模型 ID；下面的模型表列出支持的组合。 |
| `input.prompt` (`string`) | 是 | 1–20,000 characters · 描述主体、构图、场景与风格；前端限制最多 20,000 字符。 |
| `input.aspectRatio` (`string`) | 是 | 1:1 · 16:9 · 9:16 · 4:3 · 3:4 · 3:2 · 2:3 · 5:4 · 4:5 · 2:1 · 1:2 · 21:9 · 9:21 · 目标图片宽高比，取模型支持的值。 |
| `input.resolution` (`string`) | 是 | 1K · 2K · 4K · 目标清晰度，需与模型及比例组合兼容。 |
| `input.referenceImages` (`array<MediaReference>`) | 否 | 参考图数组；纯文字生图可省略。每项含 url 和 mimeType。 |

### 第 2 步：逐张生图

将 PASTE\_ONE\_CARD\_PROMPT\_FROM\_PLAN 换成对应卡片的 prompt。示例为一张；三张方案分别提交三次。

```bash 商品图片生成请求 theme={null}
curl -X POST https://customer.lululab.ai/tasks \
  -H "Authorization: $LULULAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workflowId": "ImageGenV2",
    "input": {
      "model": "gpt-image-2-5-flare",
      "prompt": "PASTE_ONE_CARD_PROMPT_FROM_PLAN",
      "aspectRatio": "9:16",
      "resolution": "1K",
      "referenceImages": [{ "url": "PRODUCT_IMAGE_URL", "mimeType": "image/jpeg" }]
    },
    "attributes": { "saveGeneratedAssets": true, "creationSource": "api" }
  }'
```

> [!NOTE]
>
> 每张卡片都要单独提交生成任务，并分别保存任务 id。标题和叠字建议可以用于你自己的后续排版流程。

* [上传参考素材](https://docs.lululab.ai/cn/uploads.md)
* [查询任务与错误](https://docs.lululab.ai/cn/task-results.md)
* [接口参考](https://docs.lululab.ai/cn/reference.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.