主题
图片与视频生成
本文说明 GoesAI 图片生成与视频生成接口的技术接入方式。接口使用同一套鉴权方式,请在请求头中携带 Authorization: Bearer sk-your-goesai-api-key。
1. 图片生成
图片生成使用 OpenAI 兼容接口。文生图不传 image 字段;单图生图传 1 张参考图;多图参考融合传 2 张或更多参考图。
Request URL:POST /v1/images/generations
1.1 文生图
bash
curl --location 'https://api.goesai.com/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-your-goesai-api-key' \
--data '{
"model": "Seedream-5.0-overseas-1",
"prompt": "一杯苹果水果茶产品图,干净白底,商业摄影风格",
"size": "1024x1024",
"n": 1
}'1.2 参考图生成
bash
curl --location 'https://api.goesai.com/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-your-goesai-api-key' \
--data '{
"model": "Seedream-5.0-overseas-1",
"prompt": "融合参考图中的杯型和水果元素,生成一张新品海报",
"image": [
"https://example.com/reference-cup.png",
"https://example.com/reference-fruit.png"
],
"size": "1024x1024",
"n": 1
}'常用参数:
| 参数 | 类型 | 说明 |
|---|---|---|
model | string | 图片模型名称,例如 Seedream-5.0-overseas-1 |
prompt | string | 图片生成提示词 |
image | string 或 string[] | 可选,参考图 URL;传多张时表示多图参考 |
size | string | 输出尺寸,例如 1024x1024 |
n | number | 输出图片数量 |
2. 视频生成
视频生成使用异步任务接口。创建任务后会返回 id 或 task_id,请使用视频查询接口轮询任务状态。
Request URL:POST /v1/video/generations
2.1 文生视频
bash
curl --location 'https://api.goesai.com/v1/video/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-your-goesai-api-key' \
--data '{
"model": "Seedance-2.0-overseas-1",
"prompt": "苹果水果茶广告,镜头缓慢推进,清爽明亮的商业视频",
"resolution": "720p",
"ratio": "16:9",
"duration": 5
}'2.2 图生视频
bash
curl --location 'https://api.goesai.com/v1/video/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-your-goesai-api-key' \
--data '{
"model": "Seedance-2.0-overseas-1",
"content": [
{"type": "text", "text": "保持参考素材中的主体,生成一段顺滑的产品展示视频"},
{"type": "image_url", "image_url": {"url": "https://example.com/reference.png"}, "role": "reference_image"}
],
"resolution": "720p",
"ratio": "16:9",
"duration": 5
}'2.3 视频输入
bash
curl --location 'https://api.goesai.com/v1/video/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-your-goesai-api-key' \
--data '{
"model": "Seedance-2.0-overseas-1",
"content": [
{"type": "text", "text": "参考输入视频的运镜,生成一段新的产品展示视频"},
{"type": "video_url", "video_url": {"url": "https://example.com/reference.mp4"}}
],
"resolution": "720p",
"ratio": "16:9",
"duration": 5
}'常用参数:
| 参数 | 类型 | 说明 |
|---|---|---|
model | string | 视频模型名称,例如 Seedance-2.0-overseas-1 |
prompt | string | 文生视频提示词 |
content | array | 可选,多模态输入;支持文本、图片 URL、视频 URL |
resolution | string | 输出分辨率,例如 480p、720p、1080p |
ratio | string | 输出比例,例如 16:9、9:16、1:1 |
duration | number | 输出视频时长,具体可用范围以模型能力为准 |
3. 查询任务
视频生成任务通常需要异步完成。创建任务后,请保存返回的任务 ID,并按接口返回状态轮询结果。
bash
curl --location 'https://api.goesai.com/v1/video/generations/{task_id}' \
--header 'Authorization: Bearer sk-your-goesai-api-key'当任务状态为成功时,响应中会包含生成结果地址;当任务失败时,请记录响应中的错误信息和请求 ID 以便排查。
