[已解决]openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host=‘api

2023-10-17 08:53:58 浏览数 (1)

openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host=‘api.openai.com’, port=443): Max retries exceeded with url: /v1/completions (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x000002AFD915E250>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond’))

问题

openai 需要外网才能链接

思路

设置正向代理或者反代

解决

代码语言:javascript复制
openai.api_base = "https://openai.wndbac.cn/v1" #在这里设置即可,需要特别注意这里的/v1是必须的,否则报错。前面的地址注意替换即可。

0 人点赞