使用指南
flux-2-klein-9b 电商产品图文生图提示词配方
用于文字渲染和高保真细节的可复制提示词结构,以及通过 hiapi API 的 curl 与 Python 请求
本页内容
为什么提示词结构比长度更重要
大多数糟糕的产品渲染并不是因为形容词太少,而是因为提示词把主体、镜头、光线和文字要求混成了一团难以区分的词语。当输出出错时,你无法判断是哪一句造成的,于是只能把整段重写,同时丢掉原本有效的部分。
结构化提示词能解决这个问题,因为描述中的每一部分都有明确归属。你每次只改一个槽位并重新渲染。如果标签文字走样,就改文字槽位。如果瓶子看起来像塑料而不是磨砂玻璃,就改材质描述。其他一切保持不变,这让迭代成本很低,也让好结果可复现。
更长的提示词并不会自动提升保真度。超过一定长度后,额外形容词会开始相互竞争:同一段里既有“glossy”又有“matte”,出现两个不同的光照方向,三种都说得过去的背景色调。模型只能对它们取平均,而平均化的提示词会产出平庸的图像。一个槽位清晰分离的短提示词,能给模型明确无歧义的指令。
本指南通篇使用五槽位配方格式:
- 主体——产品及其决定性物理属性
- 构图——取景、角度、摆放、背景
- 光线——方向、质感、阴影表现
- 文字——精确文案、位置、层级
- 负面——需要抑制的伪影短列表
下面每一节都会给出针对特定槽位的可复制字符串。你把这些字符串组装起来,在 hiapi API 上通过 flux-2-klein-9b/text-to-image 运行,并且每轮迭代只调整一个槽位。
配方骨架:主体、构图、光线、文字、负面
模板如下。请把方括号部分当作待填字段,而不是建议。
Subject: [产品名称], [主要材质], [表面处理], [一个区分性细节]
Composition: [镜头类型] of [主体摆放], [背景描述], [镜头角度]
Light: [方向] [质感] light, [阴影描述]
Text: the words "[精确文案]" in [字体风格], positioned [位置], sized [相对大小]
Negatives: [伪影], [伪影], [伪影]
一个填写完整的护肤产品示例:
Subject: amber glass dropper bottle, frosted glass body, matte black cap, a thin label band near the base
Composition: product hero shot, bottle centered on a light stone surface, soft neutral background with slight gradient, eye-level camera angle
Light: large softbox from the upper left, gentle falloff toward the right, soft contact shadow under the bottle
Text: the words "DAILY SERUM" in a clean geometric sans-serif, positioned on the label band, sized to span most of the label width
Negatives: warped lettering, duplicate labels, harsh specular hotspots
有两条规则能让这个骨架保持可靠。第一,顺序不如分离重要——这些标签(Subject:、Light:)是为了帮助你自己编辑时保持纪律,提示词稳定后就可以去掉。第二,每个槽位只保留少量具体描述词。如果一个槽位需要超过两行,你很可能在描述两张不同的图像。
每个内容槽位以十五到四十个词为目标。这个范围足以锁定产品的物理现实,又不会给模型留下编造竞争性解释的空间。
让图像文字清晰可读的配方
文字渲染最能体现提示词纪律的价值。有三个习惯能显著提升效果:引用精确文案、说明放置位置、保持字数很少。
只引用一次,且精确
把想要的文案放进引号,并且只陈述一次。在不同槽位重复同一字符串,会诱使模型把它渲染两遍。
Text: the words "AURORA" in a bold condensed sans-serif, centered on the front panel, large enough to dominate the upper third
明确指定层级
当有两个文字元素时,说明哪个是主、哪个是次,并描述它们的相对大小。
Text: primary line "COLD BREW" in a heavy serif, centered; secondary line "single origin" in a smaller light sans-serif directly beneath it, roughly one quarter the height of the primary line
把位置锚定到物理特征
“居中”太弱。“居中于前标签上,位于上边缘与瓶盖颈圈之间”则给模型提供了可用的几何信息。
Text: the words "SPF 30" in a rounded sans-serif, positioned in the lower right corner of the label, small relative to the product
保持文字简短
一到四个词能稳定渲染。完整句子、产品宣称和成分列表正是可读性崩塌为融化的字形的地方。如果你的包装确实需要一段文字,先生成干净的产品图,之后再合成真实排版——模型不是布局引擎。
适合电商标签的有效模式
- 短品牌标识:
the words "NORD" in an uppercase geometric sans-serif, tracking wide, centered on the bottle shoulder - 容量或体积:
the words "250ml" in a small regular sans-serif, bottom edge of the label, right-aligned - 品类词:
the words "BODY LOTION" in a medium-weight sans-serif, one line, spanning the label width
如果渲染结果出现乱码字符,先缩短字符串,再考虑改其他任何东西。长度是最常见的失败轴。
高保真产品细节的配方
保真度来自物理具体性,而不是形容词密度。有三个槽位承担了大部分作用:材质、表面处理和取景。
材质
说出物质名称,以及一两个可见结果。
Subject: ceramic mug, thick stoneware body, slight irregularity along the rim, speckled clay visible through the glaze
把它和 a beautiful high-quality mug 对比一下,后者没有告诉模型任何可渲染的信息。
表面处理
表面处理是渲染最常出错的地方,因为“闪亮”和“高级”并不是可执行指令。要描述光在表面上的行为。
Subject: stainless steel thermos, brushed horizontal grain, satin finish that spreads highlights into wide soft bands rather than sharp points
Subject: glass perfume bottle, clear thick-walled glass, polished facets that produce crisp edges and a visible refraction through the body
取景
借用摄影术语。这能给模型一致的镜头空间模型。
product hero shot, eye-level, centered, shallow depth of field with the background falling off softlythree-quarter angle, slightly above eye level, product occupying the lower two thirds of the frameflat lay, directly overhead, product aligned to the frame edges with even margins
真正有用的质感描述词
只有在产品确实如此时才使用这些词:brushed、frosted、matte、satin、polished、woven、knurled、embossed、anodized。每一个都对应特定的光照响应,这正是它们优于泛泛赞美词的原因。
一条完整的、面向细节的主体描述行:
Subject: matte ceramic candle jar, unglazed exterior with fine grain, smooth glazed interior lip, thin wooden lid resting slightly ajar
注意这里没有最高级形容词。每个词都在约束几何或光线。

权重与简短负面列表
强调与弱化词语
当某个槽位被忽略时,你有两个杠杆:把该词移到提示词更靠前的位置,或给它加权。加权语法因工具而异,因此在生产负载中依赖某种特定记法之前,请先确认 flux-2-klein-9b/text-to-image 在 hiapi API 上接受什么。实践中,重新排序是最可移植的修复——槽位开头附近的词比埋在末尾的词影响更大。
权重要用于真正的冲突,而不是日常强调。如果标签文字总是缩小,就给文字槽位加权,而不是给主体里的每个词加权。
让负面列表基于证据
负面列表是补丁列表,不是愿望清单。从空开始。渲染。看到某个具体伪影时,再加进去。当你不再看到它时,考虑移除它。
产品图工作的一个实用起步集合:
Negatives: warped lettering, duplicate text, extra fingers, distorted reflections
对大多数电商提示词来说,这差不多就是有用的上限。过长的负面列表会带来两个问题。第一,它们消耗原本可用于描述产品的提示词预算。第二,像 blurry 或 low quality 这类宽泛负面词,可能把模型推离你实际想要的合法柔焦背景和细腻表面纹理。
按伪影类别添加负面词:
- 文字失败:
warped lettering、duplicate text、misspelled labels - 结构失败:
asymmetric bottle、floating product、missing lid - 光照失败:
harsh specular hotspots、double shadows - 背景失败:
cluttered background、visible seams
每隔几次渲染就审查一次列表。如果某一项已经很久没出现,就删掉它,把词数花在别处。
在 hiapi API 上运行:curl 与 Python
模型 ID 是 flux-2-klein-9b/text-to-image。两种客户端发送相同的请求形状:模型标识符加一个包含组装后提示词的参数对象。请把 API key 和 base URL 替换为你的 hiapi 账户中的值。
curl
curl -X POST "$HIAPI_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer $HIAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-klein-9b/text-to-image",
"prompt": "Subject: amber glass dropper bottle, frosted glass body, matte black cap, thin label band near the base. Composition: product hero shot, bottle centered on a light stone surface, soft neutral gradient background, eye-level camera angle. Light: large softbox from the upper left, gentle falloff toward the right, soft contact shadow. Text: the words \"DAILY SERUM\" in a clean geometric sans-serif, on the label band, spanning most of the label width. Negatives: warped lettering, duplicate labels, harsh specular hotspots."
}'
Python
import os
import requests
payload = {
"model": "flux-2-klein-9b/text-to-image",
"prompt": (
"Subject: amber glass dropper bottle, frosted glass body, matte black cap, "
"thin label band near the base. "
"Composition: product hero shot, bottle centered on a light stone surface, "
"soft neutral gradient background, eye-level camera angle. "
"Light: large softbox from the upper left, gentle falloff toward the right, "
"soft contact shadow. "
"Text: the words \"DAILY SERUM\" in a clean geometric sans-serif, on the label band, "
"spanning most of the label width. "
"Negatives: warped lettering, duplicate labels, harsh specular hotspots."
),
}
response = requests.post(
f"{os.environ['HIAPI_BASE_URL']}/v1/images/generations",
headers={
"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}",
"Content-Type": "application/json",
},
json=payload,
timeout=120,
)
response.raise_for_status()
print(response.json())
调整负载
把提示词保持为由槽位变量构建出的单个组装字符串——除非 API 文档明确支持,否则不要每个槽位发一个字段。在代码中,把每个槽位存为独立变量再拼接,这样你可以按 SKU 改变背景或标签文案,而不必触碰配方其余部分。请查阅 API 参考,确认你账户下的准确端点路径和可接受参数;如果你的集成需要,也可以在那里添加输出尺寸或随机种子控制。

一个端到端的电商产品图示例
下面是一个完整、可复用的示例,适用于正在发布袋装烘焙咖啡的咖啡品牌。每个槽位都已填写,负面列表很短,文字也足够短,能稳定渲染。
Subject: matte kraft paper coffee bag with a flat bottom, folded top with a tin tie, fine paper grain visible, a rectangular label panel on the front
Composition: product hero shot, bag standing slightly right of center on a dark walnut surface, muted warm background, three-quarter angle slightly above eye level
Light: soft window light from the left, gentle gradient across the bag face, long soft shadow falling right
Text: the words "NIGHT ROAST" in a bold condensed serif on the label panel, centered; the words "250g" in a small sans-serif beneath it
Negatives: warped lettering, duplicate text, torn paper edges, harsh specular hotspots
通过前面展示的相同请求形状发送它,只替换提示词字符串:
prompt = " ".join([
"Subject: matte kraft paper coffee bag with a flat bottom, folded top with a tin tie,",
"fine paper grain visible, a rectangular label panel on the front.",
"Composition: product hero shot, bag standing slightly right of center on a dark walnut surface,",
"muted warm background, three-quarter angle slightly above eye level.",
"Light: soft window light from the left, gentle gradient across the bag face, long soft shadow falling right.",
"Text: the words \"NIGHT ROAST\" in a bold condensed serif on the label panel, centered;",
"the words \"250g\" in a small sans-serif beneath it.",
"Negatives: warped lettering, duplicate text, torn paper edges, harsh specular hotspots.",
])
payload = {"model": "flux-2-klein-9b/text-to-image", "prompt": prompt}
把第一次渲染当作检查清单来读。文字是否清晰可读且拼写正确?如果不是,缩短文案或简化字体描述。纸张纹理是否出现?如果袋子看起来像塑料,就强化材质槽位并添加表面处理描述词。阴影方向是否一致?如果看到两个阴影,说明光线槽位有冲突——移除一个光源。
每轮迭代只做一个更改,并保留那个能改善目标槽位且不劣化其他槽位的版本。把每个被接受的提示词与其输出一起保存,这样某个 SKU 的配方就永远不会丢失。
迭代:从第一次渲染到一致的图像集
单张好渲染只是演示。一致的图像集才是电商目录所需要的。目标是在固定主体、光线逻辑和文字处理的同时改变构图。
冻结身份槽位
让整个图像集中的 Subject 和 Light 保持逐字节一致。它们定义产品是什么以及如何打光。在不同镜头之间改变它们,正是让一套图看起来像来自不同品牌的原因。在代码中把它们锁定为常量,只在它们之上构建变化。
有意识地改变构图
提前写好两到三种构图字符串,并在不同 SKU 间复用:
product hero shot, centered, eye-level, neutral gradient backgroundthree-quarter angle from above, product in the lower two thirds, surface visibleflat lay, directly overhead, even margins on all sides
轮换使用固定的构图词汇,会产出一套看起来是有意设计而非随机的图像。
每个变体只替换文字槽位
如果一条产品线共享包装,那么不同 SKU 之间通常只有文字槽位会变。把它参数化,其他一切保持不变。这也是最容易失败的槽位,所以在生成整套之前,先用单一构图单独测试它。
把更改当作差异来追踪
把提示词纳入版本控制。每次提交应只改一个槽位,并附上它产生的渲染。当后续变体出现回归——比如标签突然走样——你可以追溯到具体的槽位编辑,而不是重新推导整个配方。
知道何时停止调参
如果对某个槽位连续三次编辑都没有带来可见改善,问题很可能在提示词之外:请求本身,或某个模型在当前取景下无法解析的物理细节。把该细节移出提示词并在后期处理,或者改变构图,使它不再承重。
一旦你的常量和构图词汇稳定,生成完整产品集就变成对文字和构图字符串的循环,而不是每次重新写提示词的练习。保持配方骨架固定,目录就能随之扩展。