simple-openai  by sashirestela

Java SDK for OpenAI API access

Created 3 years ago
380 stars

Top 74.6% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
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

11 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
0 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.