Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dexuby/openai4j
OpenAI API Client in Java
https://github.com/dexuby/openai4j
api-client assistants client gpt4 java openai openai-api
Last synced: 3 days ago
JSON representation
OpenAI API Client in Java
- Host: GitHub
- URL: https://github.com/dexuby/openai4j
- Owner: dexuby
- License: mit
- Created: 2023-11-08T13:38:29.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-19T19:45:37.000Z (12 months ago)
- Last Synced: 2023-11-19T20:34:40.564Z (12 months ago)
- Topics: api-client, assistants, client, gpt4, java, openai, openai-api
- Language: Java
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![](https://jitpack.io/v/dexuby/openai4j.svg)](https://jitpack.io/#dexuby/openai4j)
# openai4j
Easy to use OpenAI API Client in Java.Requirements:
- Java 17+```xml
jitpack.io
https://jitpack.io
com.github.dexuby
openai4j
...```
Latest version can be found here: https://github.com/dexuby/openai4j/releasesHas been made in a really short amount of time so currently pretty much only supports all the new Beta features like Assistants (and TTS). Method and Class names usually match the API Documentation names.
Supported API features:
- Audio
- Create speech
- Assistants
- Full support
- Threads
- Full support
- Messages
- Full support
- Runs
- Full support
- Images
- Create
Example usage:
```java
final OpenAIClient client = new OpenAIClient("");
final Assistant assistant = client.createAssistant(
AssistantCreationRequest.builder()
.model(Model.GPT_4_TURBO)
.name("Example")
.description("Just an example assistant.")
.instructions("You are a helpful assistant.")
.build()
).join();
final Thread thread = client.createThread(ThreadCreationRequest.empty()).join();
client.createMessage(thread.id(),
MessageCreationRequest.builder()
.role(Role.USER)
.content("Hey, can you tell me what time it is in New York?")
.build()
).join();
final Run run = client.createRun(thread.id(),
RunCreationRequest.builder()
.assistantId(assistant.id())
.build()
).join();
```To-do - If you want to contribute you can work on those items:
- Improve/clean up request handling.
- Support for non-Beta API features.
- Support for rate limit headers.
- Better error handling.
- ...