1.the first step is to open a vpn and get your computer connected to the international Internet.
2.install axios
3.Use axios to send a post request to openai, and most importantly, specify your vpn in the request.
const axios = require('axios');
const itRealyFuckedMe= async (input) => {
try {
let data = {
model: "gpt-3.5-turbo",
messages: [
{ "role": "user", "content": input }
]
};
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.openai.com/v1/chat/completions',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${openAIKeys}`
},
data: data,
proxy: {
/*
It depends on your real proxy configuration,
Open your proxy client and view the configuration information.
*/
host: "127.0.0.1",
port: 7890,
protocol: "http"
}
};
let completion = await axios(config)
.then((response) => {
console.log("response.data:", JSON.stringify(response.data));
return response.data.choices[0].message
})
.catch((error) => {
console.log(error);
});
return completion
} catch (error) {
console.log(error);
}
};