#7695 Invalid max_tokens value, the valid range of max_tokens is [1, 393216] (request_id: 622b6ec3-5893-442c-8f91-1816800f98ed

23.177**9 Posted at: 1 hour ago

Invalid max_tokens value, the valid range of max_tokens is [1, 393216] (request_id: 622b6ec3-5893-442c-8f91-1816800f98ed)
https://api.deepseek.com/v1/
{'model': 'deepseek-v4-flash', 'timeout': 300, 'temperature': 0.1, 'max_tokens': 1444444}:Traceback (most recent call last):
File "videotrans\translator\_openaicompat.py", line 98, in _item_task
File "videotrans\translator\_openaicompat.py", line 48, in _create_completion
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': {'message': 'Invalid max_tokens value, the valid range of max_tokens is [1, 393216] (request_id: 622b6ec3-5893-442c-8f91-1816800f98ed)', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "videotrans\util\TestSrtTrans.py", line 19, in run
File "videotrans\translator\_runner.py", line 75, in run
File "videotrans\translator\_base.py", line 72, in run
File "videotrans\translator\_base.py", line 155, 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 109, in _item_task
videotrans.configure.excepts.StopTask: Invalid max_tokens value, the valid range of max_tokens is [1, 393216] (request_id: 622b6ec3-5893-442c-8f91-1816800f98ed)
https://api.deepseek.com/v1/
{'model': 'deepseek-v4-flash', 'timeout': 300, 'temperature': 0.1, 'max_tokens': 1444444}


=
system:Windows-10-10.0.22000-SP0
version:v4.14
frozen:True
language:zh_CN
root_dir:D:/ABC

1 Replies

#1 DeepSeek reply at 1 hour ago

这是你在 DeepSeek 渠道设置里手动填写的「最大输出token(max_tokens)」超出了 API 允许的上限。

报错信息已明确说明:max_tokens 的合法范围是 [1, 393216],而你填写的是 1444444。

解决办法:

  1. 打开 菜单 → 翻译设置 → DeepSeek(或对应 OpenAI兼容/AI渠道的设置窗口)。

  2. 找到最大输出token / max_tokens 字段,把 1444444 修改为合法值,例如 8192、16384 或最大 393216 以内。

  3. 保存设置后重新执行翻译。

  4. 若同时报长度截断类错误(如 Could not parse response content as the length limit was reached),可再到 菜单 → 工具 → 高级选项 → 字幕翻译,将AI翻译渠道每批字幕行数调小(如 10~20)。

另外提示:DeepSeek 的 deepseek-v4-pro / deepseek-v4-flash 支持思考模式,若开启思考模式需要较大的 max_tokens;若不需要思考,可在设置面板中取消勾选 Thinking 复选框。

请查阅相关文档:

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
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.

Dondate via ko-fi.com

Related resource