agentic
agentic copied to clipboard
fetch failed (OpenAI API banned in certain countries like China)
Describe the feature
api request error
fetch failed
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.
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
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)"} 好像是中国地区ip被ban了,大家报错的都是在国内吗?
Can you paste the full JS/TS code that you're using to call ChatGPTAPI
?
Also, which Node.js version are you using?
您能否提供有关您看到的错误的更多详细信息,包括您如何使用此软件包的一些代码片段?此错误可能意味着几乎任何事情,如果没有更多信息,我将无法提供帮助。
{“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)”} 好像是中国地区ip被ban了,大家报错的都是在国内吗?
yes
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)"} 好像是中国地区ip被ban了,大家报错的都是在国内吗?
Sorry,maybe this is really true
same error
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11118:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///home/lizhou/projects/chatgpt/node_modules/chatgpt/build/index.js:265:25 {
cause: ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout (node:internal/deps/undici/undici:6625:28)
at node:internal/deps/undici/undici:6583:50
at Immediate._onImmediate (node:internal/deps/undici/undici:6614:13)
at process.processImmediate (node:internal/timers:471:21) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
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:
- Use a proxy and pass a custom
fetch
to theChatGPTAPI
constructor which uses you proxy. Note: you'll still need a valid OpenAI API key from their website. - Using a VPN might solve your problem, depending on how aggressive the firewall is.
- Use
ChatGPTUnofficialProxyAPI
instead ofChatGPTAPI
, which may not have the same IP bans.
axios has the "proxy" function, but chatGPTAPI use the 'origin fetch' TAT
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:
- Use a proxy and pass a custom
fetch
to theChatGPTAPI
constructor which uses you proxy. Note: you'll still need a valid OpenAI API key from their website.- Using a VPN might solve your problem, depending on how aggressive the firewall is.
- Use
ChatGPTUnofficialProxyAPI
instead ofChatGPTAPI
, which may not have the same IP bans.
Thanks for your help!
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:
- Use a proxy and pass a custom to the constructor which uses you proxy. Note: you'll still need a valid OpenAI API key from their website.
fetch``ChatGPTAPI
- Using a VPN might solve your problem, depending on how aggressive the firewall is.
- Use instead of , which may not have the same IP bans.
ChatGPTUnofficialProxyAPI``ChatGPTAPI
Thanks
Can you add a proxy option in ChatGPTAPI, please?
Can you add a proxy option in ChatGPTAPI, please?
This code can help you
npm install https-proxy-agent node-fetch
const api = new ChatGPTAPI({
fetch: (url, options = {}) => {
const defaultOptions = {
agent: require('https-proxy-agent')('http://your-proxy-address:port')
};
const mergedOptions = {
...defaultOptions,
...options
};
return require('node-fetch').default(url, mergedOptions);
}
})
Can you add a proxy option in ChatGPTAPI, please?
This code can help you
npm install https-proxy-agent node-fetch
const api = new ChatGPTAPI({ fetch: (url, options = {}) => { const defaultOptions = { agent: require('https-proxy-agent')('http://your-proxy-address:port') }; const mergedOptions = { ...defaultOptions, ...options }; return require('node-fetch').default(url, mergedOptions); } })
ok, i'm try ,Thank you!
同样的错误
TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11118:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///home/lizhou/projects/chatgpt/node_modules/chatgpt/build/index.js:265:25 { cause: ConnectTimeoutError: Connect Timeout Error at onConnectTimeout (node:internal/deps/undici/undici:6625:28) at node:internal/deps/undici/undici:6583:50 at Immediate._onImmediate (node:internal/deps/undici/undici:6614:13) at process.processImmediate (node:internal/timers:471:21) { code: 'UND_ERR_CONNECT_TIMEOUT' } }
Yes, I encountered the same mistake. My project has been put into operation in production
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:
- Use a proxy and pass a custom
fetch
to theChatGPTAPI
constructor which uses you proxy. Note: you'll still need a valid OpenAI API key from their website.- Using a VPN might solve your problem, depending on how aggressive the firewall is.
- Use
ChatGPTUnofficialProxyAPI
instead ofChatGPTAPI
, which may not have the same IP bans.
Using ChatGPTUnofficialProxyAPI
also can not in China
I can get result by using curl, but also fetch failed.
ok, i tried, but i'm fialed;
this is my code please help me check this code thanks;
const api = new ChatGPTAPI({ apiKey, fetch: (url, options = {}) => { const defaultOptions = { agent: require('https-proxy-agent')('http://127.0.0.1:8899') };
const mergedOptions = {
...defaultOptions,
...options
};
return require('node-fetch').default(url, mergedOptions);
} });
sorry to ask ; but i really want to know how to get the 'http://your-proxy-address:port' thanks
This works for me. Thanks all guys!
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
" http://proxy" this address get from where thanks
Such as http://127.0.0.1:1234 It is your Proxy address.
But I got 'Error: OpenAI error 503' sometimes.
i set this. but get no replay from openAI
It's Work