ChatGPT Java SDK. Official OpenAI API.
<dependency>
<groupId>io.github.aminovmaksim</groupId>
<artifactId>chatgpt4j</artifactId>
<version>1.0.3</version>
</dependency>
implementation 'io.github.aminovmaksim:chatgpt4j:1.0.3'
- 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
ChatRequest request = new ChatRequest("Write an essay about AI revolution");
request.setModel(ModelType.GPT_3_5_TURBO.getName());
ChatResponse response = client.sendChat(request);
System.out.println(response.getChoices().get(0).getMessage().getContent());
Join waitlist here
Project currently in develop, feel free to contact me @aminovmaksim