-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch failed (OpenAI API banned in certain countries like China) #419
Comments
same error and use http api directly is worked |
same error |
same error, error message: "fetch failed" |
maybe need use http proxy , i think... |
same error |
Can you please provide more details on the error you're seeing, including some code snippets for how you're using this package? This error could mean almost anything, and I won't be able to help without more info. |
{"err":"TypeError: fetch failed\n at Object.fetch (node:internal/deps/undici/undici:11118:11)\n at (/app/node_modules/chatgpt/build/index.js:262:25)"} |
|
Can you paste the full JS/TS code that you're using to call Also, which Node.js version are you using? |
yes |
Sorry,maybe this is really true |
same error
|
Yes, I believe that IP addresses in China are banned from calling the OpenAI API. If you have this problem, you have a few workarounds:
|
axios has the "proxy" function, but chatGPTAPI use the 'origin fetch' TAT |
Thanks for your help! |
Thanks |
Can you add a proxy option in ChatGPTAPI, please? |
This code can help you
|
ok, i'm try ,Thank you! |
Yes, I encountered the same mistake. My project has been put into operation in production |
Using |
this is my code please help me check this code thanks; const api = new ChatGPTAPI({
} |
sorry to ask ; but i really want to know how to get the 'http://your-proxy-address:port' thanks |
This works for me. import { ChatGPTAPI } from "chatgpt";
import proxy from "https-proxy-agent";
import nodeFetch from "node-fetch";
async function example() {
const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY || "",
fetch: (url, options = {}) => {
const defaultOptions = {
agent: proxy("http://proxy"),
};
const mergedOptions = {
...defaultOptions,
...options,
};
return nodeFetch(url, mergedOptions);
},
});
const res = await api.sendMessage("Hello World!");
console.log(res.text);
} |
" http://proxy" this address get from where thanks |
Such as http://127.0.0.1:1234 |
But I got 'Error: OpenAI error 503' sometimes. |
If you're looking for a proxy, check out https://www.webshare.io |
There is no reliable mainland agent recommended |
sad , It's not work for me , fxxk gfw
|
I also encountered the same problem when I started the local service using node. Starting the global proxy can be called normally in the browser, but starting the local service using node will time out. Have you solved it? |
not yet . |
I had the same issue when I tested, it's because of my proxy is socks5 and http type in different env. |
I got the same error, have you resolve it? |
How to add a proxy when directly running at the CLI, like "npx chatgpt 'your prompt here'"? I have add proxy "export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890" but it still not work. |
> 直接在 CLI 上运行时如何添加代理,例如“npx chatgpt '您的提示'”?
|
I solved this problem by nginx reverse proxy, you need a server outside the GFW
|
got the error, but I tested from oversea (australia)
|
Looks like this is unrelated to the API key. It seems that you don't have node-fetch installed or haven't configured it correctly |
I have installed There should be no configure, except the environment variable I tested in an empty folder.
let me know what I missed. |
Know the reason now. The package doesn't work with
if I test the same commands, with docker image
Please confirm. updateswork fine in docker image |
It works for me import { ChatGPTAPI } from "chatgpt";
import { HttpsProxyAgent } from "https-proxy-agent";
import nodeFetch from "node-fetch";
const api = new ChatGPTAPI({
apiKey: (process.env.NEXT_PUBLIC_OPENAI_API_KEY as string) || "",
fetch: (url, options = {}) => {
const defaultOptions = {
agent: new HttpsProxyAgent("http://127.0.0.1:7890"),
};
const mergedOptions = {
...defaultOptions,
...options,
};
return nodeFetch(url, mergedOptions);
},
});
export { api }; |
|
This project is undergoing a major revamp; closing out old issues as part of the prep process. The |
Describe the feature
api request error
fetch failed
The text was updated successfully, but these errors were encountered: