关键字
Cursor、DeepSeek、API配置、内网代理、HTTP/2
背景环境
使用Cursor集成环境开发程序。但是我使用公司的内网并不能使用cursor自带的模型,于是我就想使用DeepSeek官方的API服务。
环境:Windows 11系统
解决过程
网络检测
首先进行环境检测,在控制台中根据DeepSeek的API curl命令,检测网络是否通畅:
shell
C:\Users\wangq>curl https://api.deepseek.com
curl: (28) Failed to connect to api.deepseek.com port 443 after 21087 ms: Could not connect to server
结果:不能访问服务器
但是网页版本就可以访问,环境区别就在于浏览器走了代理(内网环境很正常)。
首先配置代理:
shell
C:\Users\wangq>set http_proxy=http://proxy-server:port
C:\Users\wangq>set https_proxy=http://proxy-server:port
C:\Users\wangq>curl https://api.deepseek.com
{
"event_id": "30-inst-5-20250318161115-8e303def",
"error_msg": "Not Found. Please check the configuration."
}
说明我的网络可以访问到DeepSeek的API
Cursor配置DeepSeek
-
添加自定义模型
-
设置DeepSeek的API Key
- 这里使用OpenAI API Key,Base URL设置:https://api.deepseek.com
- 当然也可以使用其他平台的api,比如阿里百炼,硅基流动等等。
-
其他模型冲突问题
- 暂时关闭其他自带模型,只留自定义的模型。
-
配置Cursor代理
- 在VS Code Setting中搜索proxy
- 通过修改配置的方式修改代理
在配置中添加以下代码:
json
"http.proxy": "http://proxy-server:port",
"https.proxy": "https://proxy-server:port",
"http.proxyStrictSSL": false

按理说到这一步就可以正常访问DeepSeek的API了,但是还是不行
- 禁用Http2
- 勾选Disable Http2配置
- 成功解决问题
总结
- 内网环境特殊性
- 公司代理可能对HTTP/2流量有特殊处理
- 公网环境下不需要此配置
- 问题排查思路
- 从基础网络连通性开始
- 逐步排查代理配置
- 最后考虑协议层问题
- 经验教训
- 内网环境配置需要更多调试
- 协议级别的配置可能影响API调用