/ChatGPT4J

ChatGPT Java SDK. Official OpenAI API.

Primary LanguageJavaMIT LicenseMIT

ChatGPT4J

ChatGPT Java SDK. Official OpenAI API.

Maven Central

How to install

Maven

<dependency>
    <groupId>io.github.aminovmaksim</groupId>
    <artifactId>chatgpt4j</artifactId>
    <version>1.0.2</version>
</dependency>

Gradle

implementation 'io.github.aminovmaksim:chatgpt4j:1.0.2'

How to use

  • 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());

Disclaimers

Project currently in develop, feel free to contact me @aminovmaksim