智狐AI视频平台(video.aicns.cn)是基于智创聚合API搭建的一个基于AI技术的视频生成服务平台,支持通过文本提示或图片描述生成高质量视频内容,目前已提供API给用户接入自己的AI视频应用,目前支持OpenAI的Sora系列模型和谷歌Gemini的Veo系列模型,相同视频接口可以调用不同视频模型,以下为详细教程
1. 认证方式
API Token
所有API请求都需要在请求头中包含有效的API Token:
Authorization: Bearer YOUR_API_TOKEN获取API Token
请进入官网生成n.lconai.com。
2. 请求格式
基础请求头
Authorization: Bearer YOUR_API_TOKEN Content-Type: application/json # 或 multipart/form-data (用于文件上传)请求URL
https://n.lconai.com/v1/videos3. 视频生成接口
3.1 基本文本生成视频
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| prompt | string | 是 | 视频描述文本 |
| model | string | 是 | 模型名称,如 “sora-2” |
| seconds | string | 是 | 视频时长(秒) |
| size | string | 是 | 视频分辨率,如 “1280x720” |
JSON格式请求示例
{"prompt":"一只猫在沙滩上奔跑","model":"sora-2","seconds":"4","size":"1280x720"}cURL请求示例
curl--location -g --request POST'https://n.lconai.com/v1/videos'\--header'Authorization: Bearer YOUR_API_TOKEN'\--header'Content-Type: application/json'\--data-raw'{ "prompt": "一只猫在沙滩上奔跑", "model": "sora-2", "seconds": "4", "size": "1280x720" }'3.2 带参考图片的视频生成
multipart/form-data格式请求
curl--location -g --request POST'https://n.lconai.com/v1/videos'\--header'Authorization: Bearer YOUR_API_TOKEN'\--form'prompt="牛马起飞"'\--form'model="sora-2"'\--form'seconds="4"'\--form'size="1280x720"'\--form'input_reference=@/path/to/image.png'4. 响应格式
4.1 成功响应 (HTTP 200)
{"id":"video_68e688d4950481918ec389280c2f78140fcb904657674466","object":"video","created_at":1759938772,"status":"queued","completed_at":null,"error":null,"expires_at":null,"model":"sora-2","progress":0,"remixed_from_video_id":null,"seconds":"4","size":"720x1280"}响应字段说明
| 字段名 | 类型 | 说明 |
|---|---|---|
| id | string | 视频唯一标识符 |
| object | string | 对象类型,固定为 “video” |
| created_at | integer | 创建时间戳 |
| status | string | 视频状态(queued/processing/completed/failed) |
| completed_at | integer/null | 完成时间戳 |
| error | string/null | 错误信息 |
| expires_at | integer/null | 过期时间戳 |
| model | string | 使用的模型 |
| progress | integer | 进度百分比(0-100) |
| seconds | string | 视频时长 |
| size | string | 视频分辨率 |
4.2 错误响应
{"error":{"message":"Invalid API key","type":"authentication_error","code":401}}常见错误码
| 错误码 | 类型 | 说明 |
|---|---|---|
| 401 | authentication_error | API密钥无效 |
| 400 | invalid_request | 请求参数错误 |
| 429 | rate_limit_error | 请求频率超限 |
| 500 | api_error | 服务器内部错误 |
5. 状态查询接口
查询视频状态
curl--location -g --request GET'https://n.lconai.com/v1/videos/{video_id}'\--header'Authorization: Bearer YOUR_API_TOKEN'6. 使用示例
Python示例
importrequestsimportjson# API配置API_TOKEN="YOUR_API_TOKEN"API_URL="https://n.lconai.com/v1/videos"# 请求头headers={"Authorization":f"Bearer{API_TOKEN}","Content-Type":"application/json"}# 请求数据data={"prompt":"一只猫在沙滩上奔跑","model":"sora-2","seconds":"4","size":"1280x720"}# 发送请求response=requests.post(API_URL,headers=headers,data=json.dumps(data))# 处理响应ifresponse.status_code==200:result=response.json()print(f"视频ID:{result['id']}")print(f"状态:{result['status']}")else:error=response.json()print(f"错误:{error['error']['message']}")JavaScript示例
constaxios=require('axios');constAPI_TOKEN='YOUR_API_TOKEN';constAPI_URL='https://n.lconai.com/v1/videos';asyncfunctiongenerateVideo(){try{constresponse=awaitaxios.post(API_URL,{prompt:'一只猫在沙滩上奔跑',model:'sora-2',seconds:'4',size:'1280x720'},{headers:{'Authorization':`Bearer${API_TOKEN}`,'Content-Type':'application/json'}});console.log('视频生成成功:',response.data);}catch(error){console.error('错误:',error.response.data.error.message);}}generateVideo();7. 最佳实践
7.1 提示词优化
- 使用具体、详细的描述
- 包含动作、场景、风格等信息
- 避免模糊或歧义的表达
7.2 参数选择建议
- 时长: 建议4-8秒,过长可能影响生成质量
- 分辨率: 根据实际需求选择,高分辨率需要更长的生成时间
- 模型: 使用推荐的最新模型获得最佳效果
7.3 错误处理
- 实现重试机制,处理临时性错误
- 合理设置请求间隔,避免触发频率限制
- 记录错误日志,便于问题排查
8. 注意事项
- API Token需要妥善保管,不要暴露在客户端代码中
- 遵守服务条款,不要生成违规内容
- 关注API使用配额,避免超额使用
- 定期检查API更新,及时调整集成代码
本文档基于智创聚合API最新版本编写,如有更新请以官方文档为准。