Sora2 API对接
本文介绍了AI视频生成和对话API的对接规范。基础配置包括API端点https://api.6ai.chat/v1/、POST请求方式和必需Header参数。视频生成接口支持两种模型(sora-2和sora-2-pro),需指定图片、提示词、方向、分辨率等参数,返回任务ID和状态。对话生成接口需配置对话内容、工具调用等参数。注意事项强调API仅限测试用途,必填参数需完整传递,推荐携带API Key
·
一、对接基础信息
- API基础URL:
https://api.6ai.chat/v1/(基于您提供的URL替换文档中默认服务地址) - 请求方法:所有接口均使用
POST - 通用Header参数(必需):
参数名 类型 示例值 说明 Content-Type string application/json 请求体格式 Accept string application/json 响应体格式 Authorization string(可选) Bearer {{YOUR_API_KEY}} 身份认证,建议携带以提升权限
二、异步格式对接(生成视频)
适用接口:
- sora-2:
/v1/video/create(对应文档360002820e0、360002821e0) - sora-2-pro:
/v1/video/create(https://six-ai.apifox.cn/360002822e0)
1. 核心请求参数(Body,application/json)
| 参数名 | 类型 | 必填 | 说明 | 模型差异 |
|---|---|---|---|---|
| images | array[string] | 是 | 图片链接数组(如无图可传空数组[]) |
无 |
| model | string | 是 | 模型名 | sora-2填sora-2;sora-2-pro填sora-2-pro |
| orientation | string | 是 | 视频方向 | 可选portrait(竖屏)、landscape(横屏),无模型差异 |
| prompt | string | 是 | 生成提示词(如make animate) |
无 |
| size | string | 是 | 视频分辨率 | sora-2支持small(默认720p),示例含large;sora-2-pro仅支持large(1080p) |
| duration | string | 是 | 视频时长 | sora-2枚举值10(示例用15);sora-2-pro支持15 |
2. 请求示例(curl)
(1)sora-2生成竖屏视频
curl --location --request POST 'https://api.6ai.chat/v1/video/create' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"images": ["https://filesystem.site/cdn/20250612/VfgB5ubjInVt8sG6rzMppxnu7gEfde.png"],
"model": "sora-2",
"orientation": "portrait",
"prompt": "make animate",
"size": "small",
"duration": 10
}'
(2)sora-2-pro生成横屏高清视频
curl --location --request POST 'https://api.6ai.chat/v1/video/create' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"images": [],
"model": "sora-2-pro",
"orientation": "landscape",
"prompt": "make animate",
"size": "large",
"duration": 15
}'
3. 响应说明(200成功)
(1)sora-2(文档360002820e0)响应格式
{
"id": "sora-2:task_01k6x15vhrff09dkkqjrzwhm60",
"status": "pending", // 任务状态(如pending/complete)
"status_update_time": 1759763427208 // 状态更新时间戳
}
(2)sora-2(360002821e0)& sora-2-pro响应格式
{
"id": "string",
"object": "string",
"created": 0, // 创建时间戳
"choices": [
{
"index": 0,
"message": {"role": "string", "content": "string"},
"finish_reason": "string"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
三、Chat格式对接(对话生成)
适用接口:/v1/chat/completions(对应文档360006731e0),模型为sora-2
1. 核心请求参数(Body,application/json)
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 固定填sora-2 |
| messages | array[object] | 是 | 对话数组,每个元素含role(角色,如user)、content(对话内容) |
| tools | array[string] | 是 | 模型可调用工具列表(目前仅支持函数类型) |
| tool_choice | object | 是 | 工具调用控制,如{"type":"function","function":{"name":"my_function"}} |
| stream | boolean(可选) | 否 | 默认false,true时返回增量消息流 |
| max_tokens | integer(可选) | 否 | 生成内容最大令牌数,默认不限(受模型上下文限制) |
| temperature | integer(可选) | 否 | 采样温度(0-2),越高越随机 |
2. 请求示例(curl)
curl --location --request POST 'https://api.6ai.chat/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "sora-2",
"max_tokens": 1000,
"messages": [
{
"role": "user",
"content": "an astronaut golden retriever named Sora levitates around an intergalactic pup-themed space station"
}
],
"tools": ["function:generate_animate"],
"tool_choice": {"type":"function","function":{"name":"generate_animate"}},
"stream": true
}'
3. 响应说明(200成功)
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "生成动画的参数已配置,正在处理..."},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
四、注意事项
- API仅用于测试和体验,需遵守当地法律法规,禁止非法用途;
- 所有必填参数(标记“是”)需完整传递,否则会导致请求失败;
- 响应状态码
200表示请求成功,其他状态码需检查参数或认证信息; Authorization虽为可选,但携带API Key可提升请求优先级和权限。
更多推荐


所有评论(0)