Is there an OpenAI Java API or GPT-3 Java SDK

Is there a GPT-3 Java SDK or an official OpenAI Java API? Also is it possible to create an offline tool using Java which uses GPT-3 model for summarization? Thanks

Hi bille!
There is no official clients at the moment, but there is two community implementations at the moment:


I found there’s no java library specific to building LLM applications. I built one myself.

I don’t think there is a official OpenAI Java API. I’ve build one on Github openai-java

You might want to try LangChain4j: GitHub - langchain4j/langchain4j

There is also a Java client for OpenAI: GitHub - ai-for-java/openai4j

I’ve updated to supported function call token calculation.

I’ve used the TheoKanning one and the lilittlecat one. Theo’s coverage of the OpenAI API is more complete.

I built my own Java wrapper back when gpt3 came out, but it completely broke when gpt3.5 came out with a different message format (there was much gnashing of teeth when that happened). The lilitlecat one is ultra-easy, but doesn’t cover the entire OpenAI API set. Since I wanted to get at embeddings, I switched over to Theo’s, which is a bit tricky to understand at first, but it wasn’t that bad.

Since it’s just an HTTP API call, it’s trivial, and you can see my implementation here (which is using Java Spring), that is bare bones, because I wrote it today…

But I cheated a lot, by using this conversation (below). This was my first conversation letting OpenAI assist me coding, and it’s answers (even on the free GPT-3.5) were basically perfect.

Since this is mildly interesting to Java developers I thought I’d share it, but I probably should switch to using an actual shared library like what others have mentioned.

1 Like

last version support plugin welcome use

1 Like

I’ve updated the SDK support fine-tuning which is updated on Aug 22th.

You can get it from github[openai-java].

1 Like

Theo Kanning’s openai-java repo is pretty comprehensive.

1 Like

Sashirestela’s simple-openai repo is pretty easy to use.