simple-openai  by sashirestela

Java SDK for OpenAI API access

created 2 years ago
333 stars

Top 83.6% on sourcepulse

GitHubView on GitHub
Project Summary

This Java library provides a simplified interface for interacting with the OpenAI API, targeting developers who need a straightforward way to integrate AI capabilities into their Java applications. It aims to offer a user-friendly experience comparable to Python or Node.js libraries, abstracting away complex HTTP requests and JSON parsing.

How It Works

Simple-OpenAI leverages the CleverClient library for HTTP communication and Jackson for JSON processing, with Lombok reducing boilerplate code. It exposes asynchronous operations via CompletableFuture, allowing for non-blocking API calls. For synchronous behavior, methods ending in AndPoll() can be used, which block until a specified condition is met. The library supports both Java's built-in HttpClient and Square's OkHttp for network requests, offering flexibility in configuration.

Quick Start & Requirements

  • Installation: Add Maven or Gradle dependencies.
  • Requirements: Java 11 or greater.
  • Usage: Instantiate SimpleOpenAI with an API key. Examples and detailed documentation are available.

Highlighted Details

  • Comprehensive support for OpenAI services including Audio, Chat Completions (with streaming, function calling, vision, structured outputs), Embeddings, Image generation, and the Assistants API v2.
  • Compatibility with OpenAI-compatible API providers like Gemini Vertex API, Gemini Google API, Deepseek API, Mistral API, Azure OpenAI, and Anyscale.
  • Built-in exception handling for API errors and automatic request retries with exponential backoff.
  • Supports both local and remote image inputs for multimodal chat completions.

Maintenance & Community

The project is actively maintained, with a clear contributing guide and a list of users showcasing adoption.

Licensing & Compatibility

Licensed under the MIT License, permitting commercial use and integration with closed-source projects.

Limitations & Caveats

The "Realtime" feature is noted as being in Beta. While extensive, the library is unofficial and relies on the continued compatibility of the OpenAI API.

Health Check
Last commit

1 week ago

Responsiveness

1 day

Pull Requests (30d)
7
Issues (30d)
9
Star History
38 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.