#4811 openai.BadRequestError: Error code: 400 - {'error': {'code': 'InvalidParameter', 'message': 'The parameter `max_tokens`

117.132* Posted at: 2 hours ago

The parameter max_tokens specified in the request are not valid: max_tokens and max_completion_tokens cannot be set at the same time. Request id: 02178015256463552e9685c073f630ded75ba8167c6d3849328d9:Traceback (most recent call last):
File "videotrans\util\TestSrtTrans.py", line 19, in run
File "videotrans\translator\__init__.py", line 858, in run
File "videotrans\translator\_base.py", line 72, in run
File "videotrans\translator\_base.py", line 142, 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 451, in result
File "concurrent\futures\_base.py", line 403, in __get_result
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 73, in _item_task
File "openai\_utils\_utils.py", line 298, in wrapper
File "openai\resources\chat\completions\completions.py", line 1215, in create
File "openai\_base_client.py", line 1332, in post
File "openai\_base_client.py", line 1105, in request
openai.BadRequestError: Error code: 400 - {'error': {'code': 'InvalidParameter', 'message': 'The parameter max_tokens specified in the request are not valid: max_tokens and max_completion_tokens cannot be set at the same time. Request id: 02178015256463552e9685c073f630ded75ba8167c6d3849328d9', 'param': 'max_tokens', 'type': 'BadRequest'}}


=
system:Windows-10-10.0.26200-SP0
version:v4.00
frozen:True
language:zh
root_dir:E:/win-pyvideotrans-v4.00-528

3 Replies

这是由于在翻译渠道设置中同时填写了 max_tokensmax_completion_tokens 两个参数,但该 AI 接口(如 DeepSeek 或部分 OpenAI 兼容接口)不允许同时使用这两个参数(二者互斥)。

解决方法

  1. 打开软件顶部菜单 → 翻译设置 → 你正在使用的 AI 翻译渠道(如 DeepSeek、OpenAI ChatGPT 等)的设置面板。
  2. 查看 max_tokensmax_completion_tokens 字段,删除其中一个(通常保留 max_tokens 即可,若接口提示不支持则改用 max_completion_tokens)。
  3. 保存设置后重新执行翻译。

请查阅相关文档:

下载 4.00-528 版本

请前往官网下载页面获取 v4.00-528 版本:
pyvideotrans.com/downpackage

在该页面中找到对应 Windows 的完整包(.7z 压缩包)即可。解压到非系统盘的纯英文路径后,双击 sp.exe 启动。

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.

Related resource