ChatGPT
ChatGPT copied to clipboard
A Java client for the ChatGPT API. ChatGPT 的一个 Java 客户端。
ChatGPT Java
A Java client for the ChatGPT API.
Change Log
1.0.3 - 2023-12-04
- fix #17
1.0.2 - 2023-04-24
- Support message history
1.0.1
- Support GPT-4
- Add custom API host
1.0.0
- Use official API with model
gpt-3.5-turbo
- Support proxy
0.1.0
- Initial release
- Use unofficial API
Download
Download the latest JAR or grab via Maven:
<dependency>
<groupId>com.lilittlecat</groupId>
<artifactId>chatgpt</artifactId>
<version>1.0.2</version>
</dependency>
or Gradle:
implementation 'com.lilittlecat:chatgpt:1.0.2'
Usage
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.