Closed linwentao-hexin closed 9 months ago
It seem like your having trouble 🤣
Been there... Are you developing in mainland?
I don't know if this is a network issue. Even if I use VPN, it won't work. The API keys are all correct, just like you. Who can help me
// 安装依赖
npm install node-fetch https-proxy-agent
// 修改代码 http://127.0.0.1:7890为你的代理地址
import fetch from 'node-fetch';
import {HttpsProxyAgent} from 'https-proxy-agent';
const resp = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
},
body: JSON.stringify(body),
agent: new HttpsProxyAgent('http://127.0.0.1:7890')
});
// 安装依赖 npm install node-fetch https-proxy-agent // 修改代码 http://127.0.0.1:7890为你的代理地址 import fetch from 'node-fetch'; import {HttpsProxyAgent} from 'https-proxy-agent'; const resp = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.OPENAI_API_KEY}`, }, body: JSON.stringify(body), agent: new HttpsProxyAgent('http://127.0.0.1:7890') });
感谢!!解决了
// 安装依赖 npm install node-fetch https-proxy-agent // 修改代码 http://127.0.0.1:7890为你的代理地址 import fetch from 'node-fetch'; import {HttpsProxyAgent} from 'https-proxy-agent'; const resp = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.OPENAI_API_KEY}`, }, body: JSON.stringify(body), agent: new HttpsProxyAgent('http://127.0.0.1:7890') });
谢谢!!解决了 我是个js小白,请问”// 修改代码“这一部分的代码添加在哪里啊,或者说是修改哪个文件呀?
get error while fetching ...i had add proxy to the terminal or vscode, it seems it doesn't work? ....