TheoKanning / openai-java

OpenAI Api Client in Java
MIT License
4.73k stars 1.19k forks source link

How to modify OpenAI base url ? #454

Open xcyk1226 opened 8 months ago

xcyk1226 commented 8 months ago

How to modify OpenAI base url ?

namankhurpia commented 8 months ago

just change the base URL in file- OpenAiService.java

it mentions - private static final String BASE_URL = "https://api.openai.com/";

hetao0403 commented 6 months ago

Rewrite an OpenAiService class in your own project, and after modifying the BASE-URL, you also need to modify the baseUrl in the defaultRetrofit method

cfanlu commented 5 months ago
    ObjectMapper mapper = defaultObjectMapper();
    OkHttpClient client = defaultClient(apiKey, Duration.of(timeout, ChronoUnit.SECONDS))
            .newBuilder()
            .build();
    Retrofit retrofit = OpenAiService.defaultRetrofit(client, mapper)
            .newBuilder()
            .baseUrl(baseUrl)
            .build();
    OpenAiApi api = retrofit.create(OpenAiApi.class);
    OpenAiService service = new OpenAiService(api);