Call OpenAI chat completions from a Java Spring Boot app to add AI-generated responses to your service.
Implement function calling so your Java app lets an AI model invoke custom actions like live data lookups.
Stream chat responses word by word in a Java desktop or web app so text appears progressively rather than all at once.
Transcribe audio files to text in a Java application using OpenAI's Whisper model via a simple method call.
Archived as of June 2024, no bug fixes or new features will be released by the original author, fork if you need ongoing maintenance.
This is a Java library that lets you call OpenAI's API from Java code. OpenAI makes AI models available through an API, meaning you send a request over the internet and get back a response like generated text, a transcribed audio clip, or a created image. Without a library like this, you would have to write all the networking and data formatting code yourself. This library handles that plumbing so you can focus on what you want to build. The library is split into three parts. The first is a module of data classes that match the shapes of the requests and responses OpenAI expects. The second adds a network client built on a Java library called Retrofit. The third, and the one most people will start with, is a service class called OpenAiService that wraps everything into simple method calls. You create an instance with your API key, and then call methods like createChatCompletion or createImage. Beyond basic text and image generation, the library includes support for function calling, which is a feature where you define a set of actions the AI can request and your code carries out. The README walks through a detailed example of defining a weather lookup function that the AI can choose to invoke during a conversation. Streaming responses, where text arrives in chunks rather than all at once, is also supported, along with audio transcription, file management, fine-tuning, and content moderation. For Java projects, the library is available through Maven Central and can be added to a Gradle or Maven build file with a short dependency declaration. Customization is possible by supplying your own network client configuration, which the README shows for cases like adding request logging or routing traffic through a proxy server. One important note from the README: the project was archived in June 2024 and is no longer maintained. The code remains available and forkable, but no further updates or support will come from the original author. If you need active maintenance, you would need to fork the repository or look for a different library.
← theokanning on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.