为什么我这个nodejs无法访问openai接口啊,试了好久找不到问题
我换成智谱ai源都可以成功,openai的就不行。
也试了proxy,https-proxy-agent还是不行
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^
AxiosError: connect ETIMEDOUT 128.121.243.107:443
[Symbol(kOutHeaders)]: [Object: null prototype] {
accept: [ 'Accept', 'application/json, text/plain, */*' ],
'content-type': [ 'Content-Type', 'application/json' ],
authorization: [
'Authorization',
'Bearer sk-proj-lGYGL'
],
'user-agent': [ 'User-Agent', 'axios/1.7.9' ],
'content-length': [ 'Content-Length', '71' ],
'accept-encoding': [ 'Accept-Encoding', 'gzip, compress, deflate, br' ],
host: [ 'Host', 'api.openai.com' ]
},
[Symbol(errored)]: null,
[Symbol(kHighWaterMark)]: 16384,
[Symbol(kRejectNonStandardBodyWrites)]: false,
[Symbol(kUniqueHeaders)]: null
},
_currentUrl: 'https://api.openai.com/v1/chat/completions',
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false
},
cause: Error: connect ETIMEDOUT 128.121.243.107:443
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1610:16) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '128.121.243.107',
port: 443
这是终端报的错误
如果是你的本地访问 openai 需要确保本地有🪜可以准确访问到 openai 的服务,可以尝试
是否可用,看到你截图出现的是 500 能截图一下具体的返回的是什么错误吗?