Skip to content

pdkst/models

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAI Java API Client for Models

Build Status codecov Maven Central Apache License 2.0

This is a Java client for the OpenAI API, which allows you to access models through a simple and easy-to-use interface. The client supports both synchronous and asynchronous requests, and can be easily integrated into your Java projects.

Installation

To use the OpenAI Java API Client in your project, add the following Maven dependency to your pom.xml file:

<dependency>
<groupId>io.github.pdkst.models</groupId>
<artifactId>models-openai</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

Usage

To use the OpenAI Java API Client, you first need to create an instance of the OpenAI class, which provides methods for accessing the various OpenAI APIs. You can then call the desired method with the appropriate parameters to perform the desired action.

Here's an example of how to use the OpenAI class to generate text using the model:

final OpenaiOptions options = new OpenaiOptions();
options.key("sk-**********");
OpenaiClient client = new OpenaiClient(options);
final CompletionRequest request = new CompletionRequest();
request.setModel("gpt-3.5-turbo");
request.setStream(false);
request.messages(Message.user("hello"));
final CompletionResponse response = client.chat().completion(request);
assertNotNull(response);

In this example, we create an instance of the OpenAI class with our API key, define a CompletionRequest object with the desired parameters, and use the completion.create() method to generate text using the model. Finally, we print the generated text to the console.

For more information on the available methods and parameters, please refer to the OpenAI API documentation.

Contributing

If you encounter any issues or have any suggestions for improvements, please feel free to open an issue or submit a pull request.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for more details.

About

a simple llm models client; Try test it for production right now

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages