#4786 videotrans.configure.excepts.StopTask: Error code: 401 - {'error': {'message': 'Invalid API Key', 'param': 'Please provi

39.188* Posted at: 6 hours ago

Error code: 401 - {'error': {'message': 'Invalid API Key', 'param': 'Please provide valid API Key', 'code': '401', 'type': 'invalid_key'}}:Traceback (most recent call last):
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.AuthenticationError: Error code: 401 - {'error': {'message': 'Invalid API Key', 'param': 'Please provide valid API Key', 'code': '401', 'type': 'invalid_key'}}

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\__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 75, in _item_task
videotrans.configure.excepts.StopTask: Error code: 401 - {'error': {'message': 'Invalid API Key', 'param': 'Please provide valid API Key', 'code': '401', 'type': 'invalid_key'}}


=
system:Windows-10-10.0.22631-SP0
version:v4.00
frozen:True
language:zh
root_dir:D:/kaorou

3 Replies

错误原因:401 Invalid API Key,即翻译渠道的 API Key 无效,或未填写。

解决方案:

  1. 检查 API Key 是否填写正确
    进入软件顶部菜单 → 翻译设置,找到你当前使用的 AI 翻译渠道(如 OpenAI ChatGPT、DeepSeek、Gemini 等),确认 API Key 已正确粘贴且没有多余空格或换行。
  2. 确认 API Key 的可用性

    • 如果是试用 Key,可能已过期或额度用完。
    • 建议登录对应平台官网,重新生成一个新的 Key,并复制到软件中。
  3. 若使用“兼容AI/本地模型”渠道
    还需确保 API 地址 正确(如 http://127.0.0.1:11434/v1 用于 Ollama),且对应的本地服务正在运行。
  4. 重启测试
    保存设置后,重新执行翻译任务,再次检查是否还有 401 错误。

请查阅相关文档:

怎么配置小米token plan的api key

在软件顶部菜单 → 翻译设置(或 TTS设置,取决于你打算用小米做翻译还是配音),找到 “XiaoMi AI”“XiaoMi-TTS” 面板。将你在小米 AI 平台获取的 API Key(也可能是 Token Plan 生成的 Key)填入对应输入框,保存后即可使用。

若翻译渠道选择的是 XiaoMi AI,则填写在翻译设置里;若配音渠道选择的是 XiaoMi-TTS,则填写在 TTS 设置里。注意区分两个渠道,Key 可能通用,但最好分别检查。

请查阅相关文档:

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