const chatCompletion = await openai.chat.completions.create({
messages: [{ role: 'user', content: 'hello world' }],
model: 'gpt-3.5-turbo'
});
console.log(chatCompletion.choices[0].message);
file:///Users/qy/Desktop/learn/source/node_test/node_modules/openai/core.mjs:316
throw new APIConnectionError({ cause: response });
^
APIConnectionError: Connection error.
at OpenAI.makeRequest (file:///Users/qy/Desktop/learn/source/node_test/node_modules/openai/core.mjs:316:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async main (file:///Users/qy/Desktop/learn/source/node_test/index.js:10:28) {
status: undefined,
headers: undefined,
request_id: undefined,
error: undefined,
code: undefined,
param: undefined,
type: undefined,
cause: FetchError: request to https://api.openai.com/v1/chat/completions failed, reason:
at ClientRequest.<anonymous> (/Users/qy/Desktop/learn/source/node_test/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:518:28)
at TLSSocket.socketErrorListener (node:_http_client:495:9)
at TLSSocket.emit (node:events:530:35)
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: 'system',
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT'
}
}
Node.js v20.11.0