跳转到主要内容
POST
https://ai.kaiho.cc
/
v1
/
images
/
generations
curl -X POST "https://ai.kaiho.cc/v1/images/generations" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "model": "flux-kontext-pro",
       "prompt": "将头发颜色改为蓝色",
       "image_urls": ["https://example.com/image.jpg"],
       "size": "match_input_image"
     }'
{
  "code": "success",
  "data": "task-wave17486161910001884721"
}
本接口采用异步模式。提交成功后将返回 task_id,您需要通过任务状态接口获取生成结果。生成结果的下载链接有效期为 24 小时。
curl -X POST "https://ai.kaiho.cc/v1/images/generations" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "model": "flux-kontext-pro",
       "prompt": "将头发颜色改为蓝色",
       "image_urls": ["https://example.com/image.jpg"],
       "size": "match_input_image"
     }'
{
  "code": "success",
  "data": "task-wave17486161910001884721"
}

认证方式

Authorization
string
必填
API Key 页面 获取您的密钥,并以 Bearer YOUR_API_KEY 的格式放入请求头中。

请求参数

model
string
必填
使用的模型 ID。可选值:flux-kontext-pro, flux-kontext-max
prompt
string
必填
图像生成的文本提示词。
image_urls
array
包含图片 URL 的数组。最多支持 1 张图片。必须是可公开访问的 URL,不支持 base64。
size
string
默认值:"match_input_image"
生成图像的比例或尺寸。可选值:match_input_image (存在输入图时的默认值), auto, 1:1, 4:3, 3:4, 16:9, 9:16, 3:2, 2:3, 21:9, 9:21
response_format
string
默认值:"png"
返回结果的图像格式。可选值:png, jpg
safety_tolerance
integer
默认值:"2"
内容安全容差等级,范围 0-6。
prompt_upsampling
boolean
默认值:"false"
是否开启提示词优化。

响应参数

code
string
响应状态码
  • success - 请求成功,任务已提交
data
string
任务 ID,格式为 task-wave{timestamp}{userId}{random}用于通过 查询任务状态 接口获取生成结果

注意事项

  • 接口返回 task_id 后,请前往 查询任务状态 页面了解如何获取最终图像。
  • 图像编辑功能需要提供 image_urls
  • 生成的下载链接具有时效性,请及时转存。