#2189 openai.BadRequestError: Error code: 400 - {'error': {'message':

216.238* Posted at: 10 hours ago 👁13

请求参数不正确:Error code: 400 - {'error': {'message': "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'unsupported_parameter'}}:Traceback (most recent call last):
File "videotrans\util\TestSrtTrans.py", line 19, in run
File "videotrans\translator\__init__.py", line 912, in run
File "videotrans\translator\_base.py", line 78, in run
File "videotrans\translator\_base.py", line 137, in _run_srt
File "tenacity\__init__.py", line 338, in wrapped_f
File "tenacity\__init__.py", line 477, in call
File "tenacity\__init__.py", line 378, in iter
File "tenacity\__init__.py", line 400, in
File "concurrent\futures\_base.py", line 439, in result
File "concurrent\futures\_base.py", line 391, in __get_result
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_localllm.py", line 54, in _item_task
File "openai\_utils\_utils.py", line 286, in wrapper
File "openai\resources\chat\completions\completions.py", line 1156, in create
File "openai\_base_client.py", line 1259, in post
File "openai\_base_client.py", line 1047, in request
openai.BadRequestError: Error code: 400 - {'error': {'message': "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'unsupported_parameter'}}


=
system:Windows-10-10.0.22631-SP0
version:v3.91
frozen:True
language:zh
root_dir:D:/AIkoux/AI/win-pyvideotrans-v3.91

1 Replies

这个错误是因为您使用的AI模型(可能是OpenAI的某些新模型)不支持 max_tokens 参数,需要使用 max_completion_tokens 参数替代。这是软件与新模型API的兼容性问题。

请按以下步骤解决:

  1. 检查并修改模型名称

    • 在软件主界面,点击“翻译设置”按钮。
    • 在“翻译渠道”中选择您正在使用的AI模型(例如OpenAI、Azure等)。
    • 查看“模型名称”输入框中的内容。
    • 关键操作:如果模型名称是 gpt-4ogpt-4o-mini 或任何以 o1- 开头的模型(如 o1-preview),请将其更改为 gpt-4-turbogpt-3.5-turbo。这些旧版模型兼容 max_tokens 参数。
  2. 如果必须使用新模型

    • 目前软件v3.91版本尚未适配此参数变更。
    • 您可以暂时回退到使用上述兼容的旧模型(如 gpt-4-turbo)进行翻译。
    • 或者等待软件后续更新。
  3. 验证解决

    • 修改模型名称后,重新尝试翻译任务,错误应不再出现。

如果问题依旧,或者您使用的是其他AI服务(如DeepSeek、智谱AI等),请提供您选择的“翻译渠道”和填写的“模型名称”,以便进一步分析。

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Donate: https://ko-fi.com/jianchang512

Similar issues already exist

Trending Questions