A Java client for the ChatGPT API.
- Support message history
- Support GPT-4
- Add custom API host
- Use official API with model
gpt-3.5-turbo
- Support proxy
- Initial release
- Use unofficial API
Download the latest JAR or grab via Maven:
<dependency>
<groupId>com.lilittlecat</groupId>
<artifactId>chatgpt</artifactId>
<version>1.0.1</version>
</dependency>
or Gradle:
implementation 'com.lilittlecat:chatgpt:1.0.1'
import com.lilittlecat.chatgpt.offical.ChatGPT;
public class Main {
public static void main(String[] args) {
ChatGPT chatGPT = new ChatGPT("YOUR API KEY");
String hello = chatGPT.ask("hello");
System.out.println(hello); // will be "\n\nHello! How may I assist you today?"
}
}
More examples can be found in the test.