OpenAI now provides an official Java SDK: https://github.com/openai/openai-java openai4j-examples Examples with the openai4j library: https://github.com/ralscha/openai4j