Base URL with path segments is not supported
It is possible to specify a base URL with retrofit as follows:
var retrofit = OpenAiService.defaultRetrofit(client, om)
.newBuilder()
.baseUrl("https://api.groq.com/openai/")
.build();
However, if baseUrl contains any path segments (e.g. /openai/ above) - they will be ignored because some OpenAiApi methods define absolute paths:https://github.com/TheoKanning/openai-java/blob/e7de81c29319d605703a874c3f1fa56f61122e8b/client/src/main/java/com/theokanning/openai/client/OpenAiApi.java#L69 A fix would be to remove all heading / to make v1/chat/completions.
Additionally, the behaviour of heading / is inconsistent: https://github.com/TheoKanning/openai-java/blob/e7de81c29319d605703a874c3f1fa56f61122e8b/client/src/main/java/com/theokanning/openai/client/OpenAiApi.java#L56
A temporary solution for now is to use a custom interceptor to manually insert missing path segments into every request.
change @POST("/v1/completions") to @POST("v1/completions")
interface HxOpenAiApi : OpenAiApi {
@Streaming
@POST("v1/completions")
override fun createCompletionStream(@Body request: CompletionRequest?): Call<ResponseBody?>?
}