HiAPI
博客

使用指南

通过 hiapi API 使用 seedream-4.5/text-to-image 生成电商产品图片

2026年11月3日
通过 hiapi API 使用 seedream-4.5/text-to-image 生成电商产品图片

并非每一张产品图都始于一张照片。在样品存在之前,在安排摄影师之前,或者当一场季节性促销需要在明天早上之前拿到横幅时,你需要仅凭一段文字描述就生成图片——一个干净的产品效果图、一个生活方式场景、一张带有真实清晰标题文字的宣传图。

seedream-4.5/text-to-image 就是为这种零样本场景打造的。给它一段大白话描述,它就会返回一张照片级真实的图片,无需任何参考照片——其中还包括准确的图内文字,而这正是大多数文生图模型仍然会出错的部分。在 hiapi 上,它和其他所有模型一样通过相同的异步 /v1/tasks 端点运行,价格为每张图 $0.045,分辨率为 2K 或 4K。

下面两个示例都是真实的 API 调用,展示了各自的精确提示词和生成的图像——未经任何后期编辑。

零样本生成与编辑真实照片的对比

seedream-4.5 以两个承担不同任务的模型形式发布:

  • seedream-4.5/text-to-image(本文主题)根据描述生成图片,无需输入照片。当产品还没有干净的参考照片时,当你需要一个目录中不存在的场景或概念时,或者当交付物是营销美术而非某个具体实物产品的照片时,就用它。
  • seedream-4.5/image-to-image 编辑你已有的真实产品照片,保留其精确形状和品牌标识,同时更改背景或情境——该工作流请参阅图生图电商指南。

如果你需要与某个实物 SKU 保持像素级一致,请使用编辑模型。如果你要生成全新的东西——概念渲染、季节性横幅、一个尚不存在的场景——文生图才是合适的工具,也是本文所涵盖的内容。

示例 1:由文字生成的影棚产品图

发送给模型的提示词:

a minimalist amber glass skincare serum bottle with a brushed silver cap
standing on a polished travertine surface, soft diffused window light
casting a gentle gradient shadow, sage green linen backdrop, one small
dried eucalyptus sprig beside the bottle, e-commerce product photography,
sharp focus, clean composition, no text, no logo, subtle reflection on
the stone surface

请求参数:aspect_ratio: "1:1"、resolution: "2K"。

这里没有瓶子、没有影棚,也没有摄影师——阴影的衰减、石面的反光以及柔和的窗户光全部来自描述。这正是文生图相对于编辑的优势所在:为一个仍在开发中的产品生成商品列表效果图或情绪板,大约一分钟即可完成,而不用排期拍摄。

示例 2:带有真实清晰标题文字的宣传图

文字渲染是这个模型任务中更难的一半——大多数图像生成器会产生乱码或拼写错误的文字。两个提示词,均未重试:

平铺促销横幅:

a flat-lay e-commerce marketing banner for a summer skincare sale, an
arrangement of amber glass bottles and dried botanicals on a warm
terracotta background, bold sans-serif headline text 'SUMMER GLOW SALE'
near the top in cream white lettering, smaller text 'Up to 30% Off'
beneath it in matching cream, clean modern layout with generous negative
space on the right third, professional marketing design, crisp legible
typography, warm cinematic lighting

请求参数:aspect_ratio: "4:3"、resolution: "2K"。

竖版故事图:

a vertical social media story graphic for a candle brand product launch,
a single black matte ceramic candle jar centered on a deep charcoal
gradient background, bold white headline text 'NEW ARRIVAL' near the
top, smaller subtext 'Shop the Collection' below the product, minimalist
premium aesthetic, soft rim lighting on the candle jar, generous margin
for mobile screen safe zones

请求参数:aspect_ratio: "9:16"、resolution: "2K"。

两个标题和两段副标题都拼写正确、字距均匀,并且正好放在提示词要求的位置——首次生成即如此,无需重试。正是这种可靠性让文生图可用于交付期限紧迫的促销素材:原本需要设计师制作的促销横幅或故事图,现在通过一次 API 调用即可起草完成。

直接调用 API

seedream-4.5/text-to-image 通过 hiapi 的异步任务端点运行:提交任务,轮询直到完成,然后下载结果。

curl:

curl -s -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer $HIAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream-4.5/text-to-image",
    "input": {
      "prompt": "a minimalist amber glass skincare serum bottle on a travertine surface, soft window light, sage linen backdrop, e-commerce product photography, no text",
      "aspect_ratio": "1:1",
      "resolution": "2K"
    }
  }'

响应会返回一个 task_id。轮询 GET /v1/tasks/{task_id},直到 status 为 succeeded,然后从 output[0].url 读取图片。该 URL 有时间限制——请立即下载。

Python(提交任务 + 轮询 + 下载):

import os
import time
import requests

API_BASE = "https://api.hiapi.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}"}


def generate_product_image(prompt: str, aspect_ratio: str = "1:1",
                            resolution: str = "2K") -> bytes:
    resp = requests.post(
        f"{API_BASE}/tasks",
        headers=HEADERS,
        json={
            "model": "seedream-4.5/text-to-image",
            "input": {
                "prompt": prompt,
                "aspect_ratio": aspect_ratio,
                "resolution": resolution,
            },
        },
        timeout=30,
    )
    resp.raise_for_status()
    task_id = resp.json()["task_id"]

    while True:
        poll = requests.get(f"{API_BASE}/tasks/{task_id}", headers=HEADERS, timeout=30)
        poll.raise_for_status()
        data = poll.json()
        if data["status"] == "succeeded":
            image_url = data["output"][0]["url"]
            return requests.get(image_url, timeout=30).content
        if data["status"] == "failed":
            raise RuntimeError(f"task {task_id} failed: {data.get('error')}")
        time.sleep(3)

批量生成一条产品线

同样的调用可以推广到完整产品线:一个 (name, prompt, aspect_ratio) 元组列表,每个条目对应一个任务,并按名称写盘保存。

JOBS = [
    {
        "name": "serum-hero",
        "prompt": "a minimalist amber glass skincare serum bottle on a travertine "
                   "surface, soft window light, sage linen backdrop, e-commerce "
                   "product photography, no text",
        "aspect_ratio": "1:1",
    },
    {
        "name": "sale-banner",
        "prompt": "a flat-lay e-commerce marketing banner for a summer skincare "
                   "sale, amber glass bottles on a terracotta background, bold "
                   "headline text 'SUMMER GLOW SALE', smaller text 'Up to 30% Off'",
        "aspect_ratio": "4:3",
    },
    {
        "name": "story-launch",
        "prompt": "a vertical social story graphic, a black matte ceramic candle "
                   "jar on a charcoal gradient background, bold white headline "
                   "'NEW ARRIVAL', subtext 'Shop the Collection'",
        "aspect_ratio": "9:16",
    },
]

for job in JOBS:
    image_bytes = generate_product_image(
        prompt=job["prompt"],
        aspect_ratio=job["aspect_ratio"],
        resolution="2K",
    )
    with open(f"{job['name']}.jpg", "wb") as f:
        f.write(image_bytes)
    print(f"{job['name']}: done")

按每张图 $0.045 计算,一次包含 20 个素材的季节性上新——主视觉图、横幅和故事图加在一起——成本约为 $0.90。由于每个任务都是独立的,并发提交多个 /v1/tasks 调用并并行轮询(遵守你账户的速率限制)比顺序运行列表更快。

与 seedream-5.0-pro 的对比

hiapi 还运行 seedream-5.0-pro,作为面向电商文生图工作的独立且更新的层级。两者并非同一模型:定价、分辨率选项和输出特征均有差异,seedream-5.0-pro 的工作流在其专属指南中介绍。当交付物需要可靠的图内文字——促销横幅、故事图、促销卡片——且希望价格固定为每张图 $0.045、无需围绕分辨率分级定价做规划时,seedream-4.5/text-to-image 正是应当选择的模型。

常见问题

seedream-4.5/text-to-image 接受参考照片吗? 不接受——text-to-image 只接受 prompt、aspect_ratio 和 resolution。要编辑已有的产品照片而非生成新图,请使用 seedream-4.5/image-to-image。

它支持哪些分辨率和宽高比? resolution 仅接受 2K 或 4K——没有 1K 层级。aspect_ratio 接受 1:1、4:3、3:4、16:9、9:16、2:3、3:2 和 21:9。

它能可靠地在图片内渲染标题文字吗? 能——上面两个宣传示例都在首次生成时正确渲染了多词标题和副标题,没有拼写错误,也没有乱码字形。

批量生成一条产品线的成本是多少? 无论分辨率层级如何,均为每张图 $0.045。一套 20 张图的季节性套图成本约为 $0.90;一套 100 张图的套图成本约为 $4.50。

我可以并行运行生成来加速批处理任务吗? 可以——每个任务都是独立的,因此并发提交多个 /v1/tasks 调用并并行轮询是产出大批量素材的最快方式。

亲自试一试

完整参数参考和实时定价见模型页面和定价页面。要获取该模型更多提示词范式,请参阅 seedream-4.5 文生图提示词配方。如果你的工作流从真实产品照片而非空白页面开始,seedream-4.5 图生图电商指南涵盖了直接编辑它的方法。

获取一个 API 密钥,生成你的第一张产品图或促销横幅——上面的代码今天就可以复制粘贴,针对 hiapi API 直接运行。

立即开始构建持久 AI 产物

获取 API 密钥,通过一个基于任务(task)的 API 调用图像、视频和音频模型。

阅读 API 文档