Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

请问支持代理地址吗? #234

Closed
wangpre opened this issue Apr 3, 2023 · 4 comments
Closed

请问支持代理地址吗? #234

wangpre opened this issue Apr 3, 2023 · 4 comments

Comments

@wangpre
Copy link

wangpre commented Apr 3, 2023

就是自己搭建反向代理服务,用我的域名替换 api.openai.com

@cryptoapebot
Copy link

@oursy
Copy link

oursy commented Apr 4, 2023

new OpenAiService(final OpenAiApi api, final ExecutorService executorService) use this constructor

@wangpre
Copy link
Author

wangpre commented Apr 4, 2023

https://github.com/TheoKanning/openai-java#adding-a-proxy

不是用proxy,是使用第三方的代理接口地址直接代替官方的接口地址,比如 https://api.openai-proxy.com
我想自己也用nginx搭一个反向代理服务,用来替换官方https://api.openai.com接口域名

希望可以自定义com.theokanning.openai.service.OpenAiService.BASE_URL

@xhxgit
Copy link

xhxgit commented May 20, 2023

new OpenAiService(final OpenAiApi api, final ExecutorService executorService) use this constructor

If you are not sure how to use it, you can refer to this constructor — public OpenAiService(final String token, final Duration timeout) or the example below.

ObjectMapper mapper = OpenAiService.defaultObjectMapper();
OkHttpClient client = OpenAiService.defaultClient("sr-xxxx", Duration.ofSeconds(10));
Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("https://api.notopenai.com/")
        .client(client)
        .addConverterFactory(JacksonConverterFactory.create(mapper))
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .build();
OpenAiService service = new OpenAiService(retrofit.create(OpenAiApi.class), client.dispatcher().executorService());

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

No branches or pull requests

5 participants