Same network, same api, same computer, I can use it fine in a front-end project built with vue, but suddenly it doesn’t work in a back-end project built with node.js, i.e. it’s so frustrating that it used to work in a back-end project, but suddenly it doesn’t work.
Also, OpenAI uses Cloudflare and if Cloudflare detects you are using a VPN, it will block you.
If you change VPN, you might get lucky and Cloudflare will not have registered that IP address range as a VPN, but as soon as it does (eventually it detect a VPN), then Cloudflare will block.
@ruby_coder
The real situation is that my savings are running out, I’m running out of money, and I can’t go anywhere. The more real situation is that it is very difficult to get an IT related job at the moment, please stop giving me advice that looks so positive and good, because every time I think about my real situation in the context of the advice you give me, it makes me suffer again.
I also encountered the same problem today. Accessing the OpenAI API through the server developed by nodeJs always reports request timeout -4039, and I have not tried to access it in Vue.
I am in Shanghai and I also use a VPN.
Is your problem solved now?@ inmymind1593
@a598975767
The problem you’re facing is not yet solved, but there are two possible solutions that you can consider:
Use axios and set up a proxy to make requests to OpenAI’s server. This may help bypass any network restrictions that are preventing your requests from going through. You can configure axios to use a proxy by adding a proxy property to your axios config object. Make sure that the proxy server you use is reliable and trustworthy.
Another option is to buy a server from another country. This may help if the issue is related to network restrictions imposed by your local ISP or government. However, this can be an expensive solution and may not provide a complete guarantee that the issue will be resolved.
If you live in China, the first step is to open a vpn and get your computer connected to the international Internet.
Guys,big news, i solved it. @axing4735@a598975767@ruby_coder@sps
and then :
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);
}
};
First of all, congratulations on finding a solution, you are the best!
I followed your scheme in the Vue project, executing your code through axios did solve the problem.
But when using axios in node-serve to execute your code, axios (config) is always in the Pending state, which makes me very distressed. Is there any solution?
I can confirm that the proxy information is correct.
I even changed the Proxy to pass in after being encapsulated by https-proxy-agent, but it didn’t change the result, and it was still blocked in the Pending state…
Reconfigure the axios proxy according to the fields found.
I can confirm that the problem is only within the proxy-related configuration.
If your vpn is not using https protocol, I don’t think using https-proxy-agent will work for your problem,or you need to provide additional configuration related to https, such as SSL certificate or something like that
I tested based on the example on the official website, the animal example. However, the API request has been in pending status, but it can be successful as long as I do not use the API middleware in Next.js and switch to using Axios for direct requests. I suspect that there might be an issue with the API middleware when requesting ChatGPT due to the existence of VPN, but I am not sure how to troubleshoot it. Using the API middleware is a great way because I don’t want to expose the API key. Can you help me?
When I use gpt-4 like gpt-3.5-turbo, call “https://api.openai.com/v1/chat/completions”, I get an error “ERR_BAD_REQUEST 404”, But when the model is changed to gpt-3.5-turbo, the code can access successfully.
Error: