创建图片生成请求
创建图片生成请求,为给定的提示词生成图像响应
POST
https://api.openapi.cn/v1/images/generations
认证参数
Authorization
string
header
必填
使用以下格式进行身份验证:Bearer <YOUR API KEY>
请求体
application/json
model
string
必填
对应的模型名称。为了更好地提升服务质量,我们将对本服务提供的模型进行定期变更,包括但不限于模型上下线、模型服务能力调整等,在可行的情况下,我们将通过公告、消息推送等适当方式通知您相关变更。
prompt
string
必填
图像生成的提示词
image_size
string
必填
生成图像的尺寸
batch_size
integer
必填
输出图像的数量
num_inference_steps
integer
必填
推理步骤数量
guidance_scale
number
必填
此值用于控制生成图像与给定提示词的匹配程度。值越高,生成的图像将越倾向于严格匹配文本提示。值越低,生成的图像将越具创意和多样性,可能包含更多意想不到的元素。
negative_prompt
string
可选
负面提示词
seed
integer
可选
随机种子值
image
string
可选
需要上传的图像应转换为base64格式
响应体
images
array
生成的图像列表
timings
object
时间统计信息
seed
integer
使用的随机种子值
请求示例
curl -X POST "https://api.example.com/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Kwai-Kolors/Kolors",
"prompt": "an island near sea, with seagulls, moon shining over the sea, light house",
"image_size": "1024x1024",
"batch_size": 1,
"num_inference_steps": 20,
"guidance_scale": 7.5
}'
响应示例
{
"images": [
{
"url": "https://example.com/generated-image-123456.png",
"b64_json": "base64编码的图像数据..."
}
],
"timings": {
"total_time": 3.45,
"inference_time": 2.98
},
"seed": 123456789
}