一、对接基础信息

  1. API基础URLhttps://api.6ai.chat/v1/(基于您提供的URL替换文档中默认服务地址)
  2. 请求方法:所有接口均使用POST
  3. 通用Header参数(必需):
    参数名 类型 示例值 说明
    Content-Type string application/json 请求体格式
    Accept string application/json 响应体格式
    Authorization string(可选) Bearer {{YOUR_API_KEY}} 身份认证,建议携带以提升权限

二、异步格式对接(生成视频)

适用接口:

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(可选) 默认falsetrue时返回增量消息流
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
    }
}

四、注意事项

  1. API仅用于测试和体验,需遵守当地法律法规,禁止非法用途;
  2. 所有必填参数(标记“是”)需完整传递,否则会导致请求失败;
  3. 响应状态码200表示请求成功,其他状态码需检查参数或认证信息;
  4. Authorization虽为可选,但携带API Key可提升请求优先级和权限。
Logo

助力合肥开发者学习交流的技术社区,不定期举办线上线下活动,欢迎大家的加入

更多推荐