进阶 docs.leonardo.ai 2026-11-22 15:11:20 · 0 阅读
第32章 使用 Leonardo.AI API 调用 Seedream 4.0 生成图像
Seedream 4.0本指南介绍如何通过 Leonardo.AI REST API 使用 Seedream 4.0 模型生成图像。
Sample Request
curl --request POST \
--url https://cloud.leonardo.ai/api/rest/v2/generations \
--header 'accept: application/json' \
--header 'authorization: Bearer ' \
--header 'content-type: application/json' \
--data '{
"model": "seedream-4.0",
"parameters": {
"width": 1920,
"height": 1080,
"prompt": "Koala with purple wizard hat on a skateboard",
"quantity": 2,
"guidances": {
"image_reference": [
{
"image": {
"id": "YOUR_UPLOADED_IMAGE_ID",
"type": "UPLOADED"
},
"strength": "MID"
}
]
},
"style_ids": [
"111dc692-d470-4eec-b791-3475abac4c46"
]
},
"public": false
}'
Recipe
API Request Endpoint, Headers, Parameters
Endpoint
https://cloud.leonardo.ai/api/rest/v2/generations
Headers
--header "accept: application/json" \
--header "authorization: Bearer " \
--header "content-type: application/json"
Body Parameters
ParameterTypeDefinitionguidancesobject可选。定义图像引导输入的对象,会影响生成结果。guidances.image_referencearray可选。最多可包含 6 张参考图的数组。每张参考图需包含 image.id、image.type(GENERATED 或 UPLOADED)以及 strength(LOW、MID、HIGH)。heightinteger可选。输入分辨率的高度。modelstring必填。模型标识符,设置为 seedream-4.0。promptstring必填。描述想要生成图像的文本提示词。prompt_enhancestring可选。设为 "ON" 时启用提示词增强;设为 "OFF" 时禁用。publicboolean可选。布尔值,决定生成结果是否公开(true)或私有(false)。quantityinteger可选。单次请求生成的图像数量。seedinteger可选。使用固定 seed 以保持多组生成结果的一致性。style_idsarray可选。风格 UUID 数组,用于为输出应用预设艺术风格。widthinteger可选。输入分辨率的宽度。支持 256 到 1440。
List of Style IDs
Preset StyleUUIDCinematica5632c7c-ddbb-4e2f-ba34-8456ab3ac436Creative6fedbf1f-4a17-45ec-84fb-92fe524a29efDynamic111dc692-d470-4eec-b791-3475abac4c46Fashion594c4a08-a522-4e0e-b7ff-e4dac4b6b622Portraitab5a4220-7c42-41e5-a578-eddb9fed3d75Stock Photo5bdc3f2a-1be6-4d1c-8e77-992a30824a2cVibrantdee282d3-891f-4f73-ba02-7f8131e5541b
更新于 10 个月前 此页面对你有帮助吗?
更新于 10 个月前 此页面对你有帮助吗?