您可以使用我们的 API,根据您拥有的任何商品信息生成商品名和说明。该 API 接受:
- 一个包含商品属性的可选 JSON 字典。例如,
{"brand": "MyBrand", "title": "White Tee", "size": "XL"}
。 - 可选的商品图片。例如,
{"uri": "https://my-store.com/img/1.png"}
。 - 标题格式设置选项。例如,
attribute_separator
,target_language
,attribute_order
。 - 数据标签示例。(如下所示)
首先,设置必备项。
import requests
API_KEY=""
API_ENDPOINT=""
仅根据图片获取建议的商品名,从而加快商品创建速度。
my_product_image = 'https://cdn.shopify.com/s/files/1/0653/5879/0892/products/1672082339438_550x825.jpg?v=1672082415'
payload = {}
payload |= {'output_spec': {'workflow_id': 'title', 'attribute_separator': '-'}}
payload |= {'product_info':{}}
payload['product_info'] |= {'product_image':{'uri': my_product_image}}
response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
suggested_title = response.json()['title']['text']
print(suggested_title)
Rustic Ceramic & Leather Leaves Necklace
根据说明获取建议的商品名,从而加快商品创建速度。
如果您的商品创建流程会提示用户提供图片和简短说明,您可以使用以下模式向用户建议商品名。
my_product_description = 'selling size 12 nike dunks. oh they are red by the way!'
payload = {}
payload |= {'output_spec': {'workflow_id': 'title'}}
payload |= {'product_info':{'product_attributes': {'description': my_product_description}}}
response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.json()['title']['text'])
Nike Dunks Red Size 12
根据商品名和说明获取建议的商品名,从而加快商品创建速度。
在此示例中,我们明确标记了希望 AI 识别的商品属性。
title = 'Volumizing & Lengthening Mascara - Dark Brown'
description = "This high-impact mascara delivers both voluptuous volume and dramatic length without clumping or smudging."
payload = {}
payload |= {'output_spec': {'workflow_id': 'title'}}
payload |= {'product_info':{'product_attributes': {'title': title, 'description': description, 'brand': 'Luxe Beauty'}}}
payload |= {
"title_examples": [
{
"product_info": {
"title": "Lash Paradise Volumizing & Lengthening Mascara - Waterproof - Blackest Black",
"colour": "Black"
},
"title_format": "product",
"category": "mascara",
"final_product_info": {
"product": "Mascara",
"brand": "Lash Paradise",
"mascara_type": "Volumizing & Lengthening",
"colour": "Blackest Black",
"waterproof": "Waterproof",
}
},
{
"product_info": {
"title": "Hypnose Drama Instant Full Body Volume Mascara - Black",
"colour": "Black"
},
"title_format": "product",
"category": "mascara",
"final_product_info": {
"product": "Mascara",
"brand": "Hypnose",
"sub_brand": "Drama",
"mascara_type": "Full Body Volume",
"colour": "Black",
"eye_lash_type": "All lash types"
}
}
]
}
response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.json())
{
"title": {
"text": "Luxe Beauty Dark Brown Volumizing & Lengthening Mascara"
},
"metadata": {
"metadata": {
"attributes": {
"brand": "Luxe Beauty",
"colour": "Dark Brown",
"mascara_type": "Volumizing & Lengthening",
"product": "Mascara"
},
}
}
}
通过从商品名获取建议的说明来加快商品创建速度。
如果您的商品创建流程会提示用户提供图片和商品名,您可以使用以下模式向用户建议商品说明。
my_product_title = 'Rustic Ceramic & Leather Leaves Necklace'
payload = {}
payload |= {'output_spec': {'workflow_id': 'description'}}
payload |= {'product_info':{'product_attributes': {'title': my_product_title}}}
response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.json()['description']['text'])
Rustic Ceramic & Leather Leaves Necklace is a beautiful necklace made from high-quality ceramic and leather. It features a unique design that is sure to turn heads.
通过品牌和颜色获取商品名和说明,从而加快商品创建速度。
请注意,在此示例中,我们将 workflow_id
设置为 "tide"
,以同时获取标题和说明。
payload = {}
payload |= {'output_spec': {'workflow_id': 'tide'}}
payload |= {'product_info':{'product_attributes': {'brand': 'Mr. Beast', 'color': 'purple'}}}
payload['product_info'] |= {'product_image':{'uri':'https://mrbeast.store/cdn/shop/files/0015dlv_0000_327.jpg?v=1702754475&width=500'}}
response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload)
print(response.text)
{
"title": {
"text": "Pajamas - Mr. Beast | Purple"
},
"description": {
"text": "Slip into the ultimate comfort and style with these Mr. Beast pajamas in a vibrant shade of purple. Crafted from the softest materials, these pajamas will envelop you in a cozy embrace, ensuring a restful night's sleep. The shorts feature a relaxed fit, allowing for easy movement, while the top boasts a classic design with a comfortable neckline. Whether you're lounging at home or drifting off to dreamland, these Mr. Beast pajamas are the perfect choice for a peaceful and stylish slumber."
},
}
目标语言支持
此字段用于指定 API 响应中生成的说明文本的语言。它会作为 output_spec 参数的一部分添加。
{"output_spec": {"target_language": "language"}}
示例值:
"korean" (Korean)
"english" (English)
"spanish" (Spanish)
"french" (French)
"pirate" (Pirate)
载荷的 JSON 示例
title = "Granos de café negro"
description = "Los granos de café negro en California"
payload = {}
payload |= {"output_spec":
{
"workflow_id": "description",
"target_language":"japanese", # specify language here
"attribute_order": ["scent", "product"],
"tone":"playful"}
}
payload |= {"product_info":{"product_attributes": {"description": description, "brand": "Parfums de Paris", "scent": "Floral"}}}
输出示例
{
"description": {
"text": "カリフォルニアの黒いコーヒー豆は、あなたの鼻をくすぐる、甘く、フローラルな香りです。この香りは、コーヒー豆の豊かな香りと、ジャスミンとバラの繊細な花の香りをブレンドしたものです。カリフォルニアの黒いコーヒー豆は、あなたの家を居心地の良いカフェに変え、あなたをリラックスした気分にさせてくれるでしょう。この香りは、コーヒー好きにも、フローラルな香り好きにも最適です。カリフォルニアの黒いコーヒー豆で、あなたの家を幸せな香りで満たしましょう!"
}
}
输入错误的语言代码可能会导致错误。
如果不支持相应语言或值,说明文字将默认为英语。
描述生成功能的语气个性化
为了帮助您树立品牌形象并使您的网店与众不同,您可以个性化设置生成的说明的语气。 Text API 提供两种选项:
您可以从语气列表中进行选择,以生成新的说明。该列表包含以下语气风格:
- 默认
- 调皮
- 正式
- 有说服力
- 对话
您可以提供采用品牌基调的现有说明或其他文字素材资源。LLM 将分析文本的语气,并根据以下方面生成“写作风格描述符”:
- 正式程度(例如正式、休闲)
- 详细程度(例如简洁、非常详细)
- 语气(例如,专业、信息丰富、积极、有说服力)
- 句子结构(例如,“simple sentence with few conjunctions”)
- 最常用的字词和短语