进阶 docs.leonardo.ai 2026-11-22 15:11:20 · 0 阅读

第21章 使用 Leonardo.AI API 调用 Krea 3 生成图像

Krea 3

本指南演示了如何通过 Leonardo.AI REST API 调用 Krea 3 模型生成图像。

示例请求 ``` 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": "krea/krea-3", "parameters": { "width": 1024, "height": 1024, "prompt": "Koala with purple wizard hat on a skateboard", "quality": "MEDIUM", "quantity": 2, "thinking_mode": "fast" }, "public": false }' ```

API 请求端点、请求头与参数

端点 https://cloud.leonardo.ai/api/rest/v2/generations

请求头 ``` --header "accept: application/json" \ --header "authorization: Bearer " \ --header "content-type: application/json" ```

Body 参数

ParameterTypeDefinition guidancesobject可选。定义影响生成结果的图像引导输入对象。 guidances.image_referencearray可选。最多 8 张参考图像的数组。每张图片包含必需的 image 对象(含 image.id 和 image.type,类型可为 UPLOADED、GENERATED、VARIATION、URL 或 BASE64;若类型为 URL 则使用 image.url,若为 BASE64 则使用 image.data),以及可选的 order 整数,用于设定引导顺序。 heightinteger可选。生成图像的高度(像素)。支持 256 到 3200 之间且为 16 倍数的值。默认值为 1024。 modelstring必需。模型标识符。设置为 krea/krea-3。 promptstring必需。描述期望生成图像内容的文本提示词。支持最多 5000 个字符。 publicboolean可选。布尔标志,决定生成结果是公开(true)还是私有(false)。 qualitystring可选。模型在生成图像前的规划程度。支持 LOW、MEDIUM 或 HIGH。HIGH 质量需要至少一张图像参考,且费用更高。默认值为 MEDIUM。 quantityinteger可选。单次请求生成的图像数量。支持 1 到 8。默认值为 4。 seedinteger可选。应用固定种子值以在多次生成中保持一致性。支持 0 到 2147483647。 thinking_modestring可选。控制生成速度与细节的平衡。支持 slow 或 fast。slow 生成细节最丰富的图像,fast 生成速度更快。默认值为 fast。 widthinteger可选。生成图像的宽度(像素)。支持 256 到 3200 之间且为 16 倍数的值。默认值为 1024。

25 天前更新 该页面有帮助吗?

评论 (0)