Skip to content
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

Use proxy to access openai for Chinese users? #52

Closed
kun-ecology opened this issue Aug 11, 2023 · 3 comments
Closed

Use proxy to access openai for Chinese users? #52

kun-ecology opened this issue Aug 11, 2023 · 3 comments

Comments

@kun-ecology
Copy link

As a Chinese user, I came across this error when using gpttools:
! Timeout was reached: [api.openai.com] Resolving timed out after 10012 milliseconds

I guess it is due to the proxy. I am using Clash and I tried to add the local proxy in .Renviron file following this, but it still gives me the error.

Thanks in advance and looking forward to your reply!

Best regards
Kun Guo

@JamesHWade
Copy link
Owner

Over in gptstudio, it was solved by allowing a different URL in place of the default openai url. Would that be an option for you?

@kun-ecology
Copy link
Author

Thanks so much for your reply.

I guess you are referring to these two issues:

However, I did not manage to fix it with them.

Nevertheless, I followed this post accessing github from behind corporate proxy - RStudio IDE - Posit Community and it works now!

The key is to run the following code:

Sys.setenv(http_proxy="http://your_proxy_ip:your_proxy_port")
Sys.setenv(http_proxy_user="http://your_proxy_ip:your_proxy_port")
Sys.setenv(https_proxy="http://your_proxy_ip:your_proxy_port")
Sys.setenv(https_proxy_user="http://your_proxy_ip:your_proxy_port")

I add these codes to the .Rprofile.site file, so I do not need to rerun them for every project.

Perhaps this is not an elegant way to establish the connection via proxy, but it works and I hope it is useful for anyone who comes across the same problem.

Best
Kun

@JamesHWade
Copy link
Owner

@kun-ecology, it looks like you were able to solve the issue, but please reopen if it is not working.

Sorry for the very delayed reply. I've been out on parental leave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants