ChatGPT Java SDK. Official OpenAI API.
<dependency>
<groupId>io.github.aminovmaksim</groupId>
<artifactId>chatgpt4j</artifactId>
<version>1.0.2</version>
</dependency>
implementation 'io.github.aminovmaksim:chatgpt4j:1.0.2'
- Initialize the client
ChatGPTClient client = ChatGPTClient.builder()
.apiKey("YOUR_KEY")
.requestTimeout(30000L) // optional, default is 60000 ms
.baseUrl("https://api.openai.com/v1") // optional
.build();
You can get your api key here
- Send a message
ChatResponse response = client.sendChat(new ChatRequest("Hello"));
System.out.println(response.getChoices().get(0).getMessage().getContent());
Project currently in develop, feel free to contact me @aminovmaksim