Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lilittlecat/chatgpt
A Java client for the ChatGPT API. ChatGPT 的一个 Java 客户端。
https://github.com/lilittlecat/chatgpt
chatgpt chatgpt-api chatgpt-java java
Last synced: about 2 months ago
JSON representation
A Java client for the ChatGPT API. ChatGPT 的一个 Java 客户端。
- Host: GitHub
- URL: https://github.com/lilittlecat/chatgpt
- Owner: LiLittleCat
- License: mit
- Created: 2022-12-07T12:55:38.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-07T01:14:14.000Z (about 1 year ago)
- Last Synced: 2023-12-07T02:50:23.323Z (about 1 year ago)
- Topics: chatgpt, chatgpt-api, chatgpt-java, java
- Language: Java
- Homepage:
- Size: 239 KB
- Stars: 79
- Watchers: 4
- Forks: 30
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChatGPT Java
[![Maven Central](https://img.shields.io/maven-central/v/com.lilittlecat/chatgpt?style=for-the-badge)](https://central.sonatype.com/artifact/com.lilittlecat/chatgpt)
A Java client for the [ChatGPT API](https://platform.openai.com/docs/guides/chat).
## Change Log
### 1.0.3 - 2023-12-04
- fix [#17](https://github.com/LiLittleCat/ChatGPT/issues/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](https://search.maven.org/remote_content?g=com.lilittlecat&a=chatgpt&v=LATEST) or grab via [Maven](https://central.sonatype.dev/artifact/com.lilittlecat/chatgpt/1.0.0):
```xml
com.lilittlecat
chatgpt
1.0.2```
or Gradle:
```groovy
implementation 'com.lilittlecat:chatgpt:1.0.2'
```## Usage
```java
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](./src/test/java/ChatGPTTest.java).
## Happy coding