': {'message': 'User error', 'type': 'video_generation_user_error', 'param': Non...

2025年12月03日 10:54 状态: processing

🚨 错误信息

调用Sora-2生成视屏,出现下面报错,{'error': {'message': 'User error', 'type': 'video_generation_user_error', 'param': None, 'code': None}}

🤖 AI解决方案

错误翻译

原文:User error
译文:用户错误

原因分析
这是一个API调用参数错误,具体原因可能是:

  • 输入参数格式不符合Sora-2 API要求

  • 缺少必要的请求参数

  • 参数值超出允许范围或格式不正确
  • 解决方案

    python

    正确的API调用示例


    import requests

    确保使用正确的参数格式


    payload = {
    "model": "sora-2",
    "prompt": "清晰的视频描述文本", # 必填参数
    "size": "1024x576", # 正确的分辨率格式
    "duration": 10, # 合理的视频时长(秒)
    "quality": "standard" # 有效的质量参数
    }

    headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
    }

    response = requests.post(
    "https://api.openai.com/v1/videos/generations",
    json=payload,
    headers=headers
    )

    预防措施

  • 参数验证:在调用API前验证所有参数的类型、格式和取值范围

  • 文档参考:仔细阅读Sora-2 API官方文档,确保参数名称和格式完全匹配
  • 请检查您的请求参数是否符合API文档要求,特别是prompt、size、duration等关键参数。