": {\n "message": "User error",\n "type": "video_generation_user_error",\n "para...
🚨 错误信息
(TraeAI-3) C:\Users\youxi\Desktop\AI调用 [0:0] $ uv run py Gen_Video.py
400
{'message': '{\n "error": {\n "message": "User error",\n "type": "video_generation_user_error",\n "param": null,\n "code": null\n }\n}', 'data': {'data': {'code': 'fail_to_fetch_task', 'message': '{\n "error": {\n "message": "User error",\n "type": "video_generation_user_error",\n "param": null,\n "code": null\n }\n}', 'type': 'task_error'}, 'message': '{\n "error": {\n "message": "User error",\n "type": "video_generation_user_error",\n "param": null,\n "code": null\n }\n}'}}
🤖 AI解决方案
报错分析
1. 错误翻译
原文:User error
译文:用户错误
原文:video_generation_user_error
译文:视频生成用户错误
原文:fail_to_fetch_task
译文:获取任务失败
2. 原因分析
这是一个视频生成API调用错误,根本原因是用户输入参数不正确或不符合要求。具体表现为:- API返回400状态码(客户端错误)
- 错误类型为
video_generation_user_error(视频生成用户错误) - 任务是
fail_to_fetch_task(获取任务失败)
3. 解决方案
检查并修正Gen_Video.py中的API调用参数:
# 常见需要检查的参数:
# 1. 确保prompt参数符合要求
prompt = "你的视频描述文字" # 确保非空且格式正确
# 2. 检查视频尺寸设置
width = 1024 # 确保是支持的尺寸
height = 576 # 确保是支持的尺寸
# 3. 验证API密钥和认证
api_key = "your_valid_api_key" # 确保密钥有效且有权访问
# 4. 检查文件路径和格式
video_path = "valid_path.mp4" # 确保路径存在且格式支持
4. ️ 预防措施
try:
# API调用代码
response = api.generate_video(**params)
if response.status_code != 200:
print(f"详细错误: {response.text}")
except Exception as e:
print(f"API调用异常: {str(e)}")
建议检查: