#7032 [deepseek] 无法连接到 https://api.deepseek.com/v1/,可能当前网络不可访问该API, 若是本地服务,请确认已部署并启动Connection error.:Traceback (most recent c

2409**1518 Posted at: 1 day ago

[deepseek] 无法连接到 https://api.deepseek.com/v1/,可能当前网络不可访问该API, 若是本地服务,请确认已部署并启动
Connection error.:Traceback (most recent call last):
File "httpx\_transports\default.py", line 101, in map_httpcore_exceptions
File "httpx\_transports\default.py", line 250, in handle_request
File "httpcore\_sync\connection_pool.py", line 216, in handle_request
File "httpcore\_sync\connection_pool.py", line 196, in handle_request
File "httpcore\_sync\connection.py", line 101, in handle_request
File "httpcore\_sync\http11.py", line 143, in handle_request
File "httpcore\_sync\http11.py", line 93, in handle_request
File "httpcore\_sync\http11.py", line 151, in _send_request_headers
File "contextlib.py", line 153, in exit
File "httpcore\_exceptions.py", line 14, in map_exceptions
httpcore.LocalProtocolError: Illegal header value b'Bearer sk-0d1a64f6410a48f0b741f1fa18a6c4c4 '

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

Traceback (most recent ca
......
e 979, in _send_handling_redirects
File "httpx\_client.py", line 1014, in _send_single_request
File "httpx\_transports\default.py", line 249, in handle_request
File "contextlib.py", line 153, in exit
File "httpx\_transports\default.py", line 118, in map_httpcore_exceptions
httpx.LocalProtocolError: Illegal header value b'Bearer sk-0d1a64f6410a48f0b741f1fa18a6c4c4 '

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

Traceback (most recent call last):
File "videotrans\translator\_openaicompat.py", line 90, in _item_task
File "videotrans\translator\_openaicompat.py", line 51, 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 1072, in request
openai.APIConnectionError: Connection 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 67, in run
File "videotrans\translator\_base.py", line 71, in run
File "videotrans\translator\_base.py", line 209, 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 92, in _item_task
videotrans.configure.excepts.StopTask: [deepseek] 无法连接到 https://api.deepseek.com/v1/,可能当前网络不可访问该API, 若是本地服务,请确认已部署并启动
Connection error.


=
system:Windows-10-10.0.19044-SP0
version:v4.11
frozen:True
language:zh
root_dir:C:/pyvideotrans

1 Replies

#1 DeepSeek reply at 1 day ago

核心原因是:你的 DeepSeek API Key 字符串中包含多余的空格

错误日志明确显示 Illegal header value b'Bearer sk-...c4c4 ',即 Bearer 后有两个空格、且密钥末尾也有空格,这导致 HTTP 请求头格式非法,从而被判为“连接错误”。这并非网络问题,而是密钥格式错误。

解决方法

  1. 打开软件 菜单 → 翻译设置 → DeepSeek
  2. 将密钥框中的内容全部删除
  3. 重新从 DeepSeek 开放平台复制密钥(注意复制时不要带上前后空格)。
  4. 粘贴后检查密钥两端是否干净:前面只能是 sk-,后面不能有空格或换行。
  5. 保存后,重新测试翻译或执行任务。

补充说明

  • 如果密钥确认无误后仍报“无法连接”,再检查主界面“网络代理”是否填写了有效代理(若不用代理请清空),以及本地网络能否访问 api.deepseek.com。
  • DeepSeek 为国内 API,默认不走代理,若你设置了无效代理,请清空后再试。

请查阅相关文档:

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