Skip to the content.

Intelligent Java

Maven Central GitHub

Intelligent java (IntelliJava) is the ultimate tool to integrate with the latest language models and deep learning frameworks using java. The library provides an intuitive functions for sending input to models like ChatGPT and DALL·E, and receiving generated text, speech or images. With just a few lines of code, you can easily access the power of cutting-edge AI models to enhance your projects.

The supported models:

How to use

  1. Add the maven dependency or import the core jar file (check the Integration section).
  2. Add Gson dependency if using the jar file; otherwise, it’s handled by maven or Gradle.
  3. Call the RemoteLanguageModel for the language models, RemoteImageModel for image generation, RemoteSpeechModel for text to speech models, and Chatbot for ChatGPT.


The package released to Maven Central Repository:




implementation 'io.github.barqawiz:intellijava.core:0.8.0'



Jar download: intellijava.jar.

Code Example

Language model code (2 steps):

// 1- initiate the remote language model
String apiKey = "<add-openai-api-key>";
RemoteLanguageModel langModel = new RemoteLanguageModel(apiKey, "openai");

// 2- call generateText with any command !
LanguageModelInput langInput = new LanguageModelInput.Builder("Summarize the plot of the 'Inception' movie in two sentences")
String resValue = langModel.generateText(langInput);

Output:Inception follows Dom Cobb, a professional thief, who is offered a chance at redemption in exchange for planting an idea in a target's mind. He must navigate a dangerous landscape of dream-sharing technology and battle his inner demons in order to complete the mission and find his way back to reality.

Image generation code (2 steps):

// 1- initiate the remote image model
RemoteImageModel imageModel = new RemoteImageModel(apiKey, "openai");

// 2- call generateImages with any command !
ImageModelInput imageInput = new ImageModelInput.Builder("teddy writing a blog in times square")
List<String> images = imageModel.generateImages(imageInput);


ChatGPT code:

// 1- initiate the chat model.
Chatbot bot = new Chatbot(apiKey, "openai");

// 2- prepare the chat history by calling addMessage.
String mode = "You are a helpful astronomy assistant.";
ChatModelInput input = new ChatGPTInput.Builder(mode)
               .addUserMessage("what is the space between moon and earth").build();

// 3- call chat!
List<String> resValues =;

Output:The average distance between the Moon and the Earth is about 238,855 miles (384,400 kilometers).

Text to speech code (2 steps):

// 1- initiate the remote speech model
RemoteSpeechModel model = new RemoteSpeechModel(apiKey,;

// 2- call generateEnglishText with any text
Text2SpeechInput input = new Text2SpeechInput.Builder("Hi, I am Intelligent Java.").build();
byte[] decodedAudio = model.generateEnglishText(input);


Sam · Intelligent Java Intro

For full example check the sample_code project.


Third-party dependencies

The only dependencies is GSON. Required to add manually when using IntelliJava jar. However, if you imported this repo through Maven, it will handle the dependencies.


Call for contributors:


Apache License

Copyright 2023

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at