创建生成任务

使用 Buble 创建异步图片与视频生成任务。

创建生成任务

使用 POST /api/v1/generations 创建异步生成任务。

Endpoint

POST /api/v1/generations
Content-Type: application/json

请求体

字段类型必填说明
modelstring/api/v1/models 返回的模型 key。
modestring推荐公开操作模式;当输入形态可能匹配多个 mode 时必须传。
promptstring文本指令;大多数 mode 都需要。
image_urlsstring array支持该输入的 mode 使用的参考图/源图片 URL。
start_framestring首帧图片 URL。
end_framestring支持首尾帧 mode 的尾帧图片 URL。
video_urlsstring array视频输入类 mode 使用的源视频 URL。
audio_urlsstring array音频输入类 mode 使用的源音频 URL。
is_publicboolean默认 false
copy_protectedboolean默认 true

/api/v1/models 返回的模型专属参数也直接放在请求体根层级,例如 durationresolutionaspect_ratiooutput_formatweb_searchaudio

媒体输入字段

字段类型常见 mode
image_urlsstring arrayimage_to_imagereference_to_video
start_framestringframes_to_video
end_framestring支持首尾帧的 frames_to_video
video_urlsstring arrayvideo_to_videovideo_editvideo_extension
audio_urlsstring array支持音频输入的视频 mode

不接受内部字段

不要传递 inputoptions,也不要传递 scenesub_mode_idsubModeIdprovidermediaTypemedia_type。公开接口请使用扁平字段和 mode

示例:文生图

curl https://buble.ai/api/v1/generations \
  -H "Authorization: Bearer $BUBLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/nano-banana-pro",
    "mode": "text_to_image",
    "prompt": "A cinematic product photo of a premium ceramic coffee grinder on a walnut counter",
    "aspect_ratio": "1:1",
    "resolution": "1K",
    "output_format": "png"
  }'

示例:首帧视频

curl https://buble.ai/api/v1/generations \
  -H "Authorization: Bearer $BUBLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/veo3.1-fast",
    "mode": "frames_to_video",
    "prompt": "The camera slowly pushes in as morning light moves across the product surface, elegant cinematic motion",
    "start_frame": "https://example.com/product-start.png",
    "duration": "8s",
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }'

JavaScript 示例

const response = await fetch('https://buble.ai/api/v1/generations', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BUBLE_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'google/nano-banana-pro',
    mode: 'text_to_image',
    prompt: 'A clean editorial product image of a smart desk lamp',
    aspect_ratio: '1:1',
    resolution: '1K',
    output_format: 'png',
  }),
});

const { data, error } = await response.json();
if (error) throw new Error(error.message);
console.log(data.id);