API 文档

网关派提供 AI 生图服务接口,通过 API Key 认证调用。所有请求需携带认证头,图片以 URL 形式传入(支持 png / jpg / webp,单张不超过 50MB),接口返回 base64 编码的生成图片。

API Key 认证

每个请求需携带有效密钥

简单调用

RESTful JSON 接口,curl 即可接入

安全稳定

密钥隔离,用量透明可查

认证

在用户中心创建 API Key 后,通过请求头携带密钥进行认证,支持以下两种方式(任选其一):

# 方式一:Authorization 头(推荐)
Authorization: Bearer gw-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# 方式二:X-Api-Key 头
X-Api-Key: gw-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

获取密钥

登录后进入 用户中心 → API Keys → 创建密钥。密钥仅创建时展示一次,请妥善保管;如泄露可删除后重建。

万物上身

POST

传入 1 张模特图(可为空)与 1-5 张产品图,系统自动分析产品特性,将商品自然穿在模特身上,生成真实照片风格的上身效果图。

POST /gw/v1/products/wear-anything

请求参数

参数类型说明
model_imagestring模特图地址,可为空;为空时自动生成符合产品特性的模特
product_images*string[]产品图地址数组,最多 5 张
promptstring补充描述,留空使用默认文案
resolutionstring清晰度:1K / 2K / 4K,默认 1K
ratiostring图片比例:4:3 / 3:4 / 9:16 / 16:9 / 1:1 / 3:2 / 2:3 / 21:9,默认 1:1

请求示例

curl -X POST "https://www.paycgi.com/gw/v1/products/wear-anything" \
  -H "Authorization: Bearer gw-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model_image": "https://cdn.example.com/model.jpg",
    "product_images": [
      "https://cdn.example.com/shirt-1.jpg",
      "https://cdn.example.com/shirt-2.jpg"
    ],
    "prompt": "简约通勤风,搭配浅色牛仔裤",
    "resolution": "1K",
    "ratio": "4:3"
  }'

鞋子上脚

POST

传入 1 张脚部图(可为空)与鞋子产品图,自动将鞋子自然穿在脚上,贴合脚型,角度自然。

POST /gw/v1/products/shoes-on-feet

请求参数

参数类型说明
foot_imagestring脚部图地址,可为空;为空时自动生成适合展示该鞋子的脚部
product_images*string[]鞋子产品图地址数组,最多 5 张
promptstring补充描述,留空使用默认文案
resolutionstring清晰度:1K / 2K / 4K,默认 1K
ratiostring图片比例,默认 1:1

请求示例

curl -X POST "https://www.paycgi.com/gw/v1/products/shoes-on-feet" \
  -H "Authorization: Bearer gw-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "foot_image": "https://cdn.example.com/foot.jpg",
    "product_images": [
      "https://cdn.example.com/sneaker-1.jpg"
    ],
    "prompt": "户外运动场景,抓地力强",
    "resolution": "2K",
    "ratio": "1:1"
  }'

眼镜试戴

POST

传入 1 张人脸图(可为空)与眼镜产品图,自动将眼镜自然佩戴在人脸上,位置准确,符合脸型。

POST /gw/v1/products/glasses-try-on

请求参数

参数类型说明
face_imagestring人脸图地址,可为空;为空时自动生成适合展示该眼镜的人脸
product_images*string[]眼镜产品图地址数组,最多 5 张
promptstring补充描述,留空使用默认文案
resolutionstring清晰度:1K / 2K / 4K,默认 1K
ratiostring图片比例,默认 1:1

请求示例

curl -X POST "https://www.paycgi.com/gw/v1/products/glasses-try-on" \
  -H "Authorization: Bearer gw-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "face_image": "https://cdn.example.com/face.jpg",
    "product_images": [
      "https://cdn.example.com/glasses-1.jpg"
    ],
    "prompt": "商务精英风格",
    "resolution": "1K",
    "ratio": "3:4"
  }'

项链试戴

POST

传入 1 张人像图(可为空)与项链产品图,自动将项链自然佩戴在人像颈部,位置准确,造型自然。

POST /gw/v1/products/necklace-try-on

请求参数

参数类型说明
portrait_imagestring人像图地址,可为空;为空时自动生成适合展示该项链的人像
product_images*string[]项链产品图地址数组,最多 5 张
promptstring补充描述,留空使用默认文案
resolutionstring清晰度:1K / 2K / 4K,默认 1K
ratiostring图片比例,默认 1:1

请求示例

curl -X POST "https://www.paycgi.com/gw/v1/products/necklace-try-on" \
  -H "Authorization: Bearer gw-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "portrait_image": "https://cdn.example.com/portrait.jpg",
    "product_images": [
      "https://cdn.example.com/necklace-1.jpg"
    ],
    "prompt": "晚宴礼服搭配",
    "resolution": "4K",
    "ratio": "2:3"
  }'

种草图

POST

传入 1-5 张产品图与描述,生成构图精美、氛围感强的种草展示图,适合社交平台分享。

POST /gw/v1/products/grass-planting

请求参数

参数类型说明
product_images*string[]产品图地址数组,最多 5 张
promptstring补充描述,留空使用默认文案
resolutionstring清晰度:1K / 2K / 4K,默认 1K
ratiostring图片比例,默认 1:1

请求示例

curl -X POST "https://www.paycgi.com/gw/v1/products/grass-planting" \
  -H "Authorization: Bearer gw-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "product_images": [
      "https://cdn.example.com/product-1.jpg",
      "https://cdn.example.com/product-2.jpg"
    ],
    "prompt": "高级感家居氛围,暖色调",
    "resolution": "1K",
    "ratio": "4:3"
  }'

响应格式

所有接口统一返回 JSON 结构:code 为业务状态码, 成功时为 200;data.b64_json 为 base64 编码的 PNG 图片,可直接用于<img src="data:image/png;base64,..."> 展示。

{
  "code": 200,
  "message": "OK",
  "data": {
    "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
    "width": 1024,
    "height": 1024
  }
}

错误码

Code说明
200请求成功
401API Key 无效或未携带,请检查认证头
403API Key 已被禁用
500服务内部错误,生图服务不可用或请求超时