Skip to content

zortan3301/ChatGPT4J

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.3</version>
</dependency>

Gradle

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

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

GPT-4

Join waitlist here


Disclaimers

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

About

ChatGPT Java SDK. Official OpenAI API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages