StefanBratanov / jvm-openai

A minimalistic OpenAI API client for the JVM, written in Java 🤖
Apache License 2.0
35 stars 8 forks source link

Ability to call self hosted OpenaiCompatible endpoints #6

Closed bks5881 closed 1 month ago

bks5881 commented 2 months ago

Just a thought, many companies are hosting their own versions of "Chat" where the url and model name changes. Would be helpful to have that feature to change them.Sometimes same url but different params.

StefanBratanov commented 2 months ago

Hi, thanks for raising this issue. You can do:

OpenAI openAI = OpenAI.newBuilder(apiKey).baseUrl("http://localhost:8080").build();

And it will initialize with a custom url and also all endpoints accept passing the model as a String. Is there any other functionality that is missing?

StefanBratanov commented 1 month ago

Hi @bks5881 is the above example enough for your use case?

bks5881 commented 1 month ago

@StefanBratanov thanks. Is the error handler only for streaming or I can have personal error handlers for syncronous calls as well?

StefanBratanov commented 1 month ago

No worries, all methods throw OpenAIException in case an error happens when calling the API, so you can catch it.

StefanBratanov commented 1 month ago

Will close this issue for now. Feel free to comment for any further discussion.