chatgpt-java logo

chatgpt-java

Free

3.4k

FreeFree tier
Inputs: text, image, audioOutputs: text, image, audio
Type
Open Source

About chatgpt-java

ChatGPT-Java is an unofficial, community-maintained Java SDK designed to provide a comprehensive client for OpenAI's official APIs. It enables Java developers to integrate a wide range of OpenAI capabilities into their applications, including chat completions (GPT-3.5, GPT-4), image generation (DALL-E 3), text-to-speech (TTS), speech-to-text, embeddings, fine-tuning, file management, and moderation. The SDK supports both streaming output (via SSE and WebSocket) and standard synchronous requests, and it includes features such as token calculation, custom OkHttpClient configuration, dynamic key management for handling API key issues, and plugin mode support. The project is open source under an MIT license and is actively maintained on GitHub.

Key Features

Supports OpenAI official APIs including chat, images, audio, embeddings, fine-tuning, files, moderations, and models
Streaming output support via SSE and WebSocket for real-time responses
Token calculation using TikToken for accurate usage tracking
Dynamic API key management with custom handling for invalid or expired keys
Plugin mode support for extending functionality
Customizable OkHttpClient for network configuration
Comprehensive documentation and community support

Pros & Cons

Pros
  • Open source and free to use under MIT license
  • Comprehensive coverage of OpenAI's API endpoints
  • Streaming output support for real-time interactions
  • Active community and documentation available
  • Supports dynamic key management for production resilience
Cons
  • Unofficial SDK; not maintained by OpenAI, so API changes may require updates
  • Requires an OpenAI API key and associated usage costs
  • Free tier of OpenAI API has rate limits and usage caps that apply
  • Documentation is primarily in Chinese; English documentation may be less complete
  • Dependency on external libraries (OkHttp) may introduce version conflicts

Best For

Building Java-based chatbots and conversational AI applicationsIntegrating image generation (DALL-E 3) into Java applicationsAdding text-to-speech and speech-to-text capabilities to Java projectsDeveloping AI assistants with custom knowledge basesFine-tuning OpenAI models for specialized tasksImplementing content moderation and text analysis features

FAQ

Is ChatGPT-Java an official OpenAI SDK?
No, it is an unofficial, community-maintained library. It aims to provide a Java client for OpenAI's official APIs, but it is not developed or endorsed by OpenAI.
Does the SDK support streaming responses?
Yes, it supports streaming output via SSE and WebSocket, allowing real-time data flow from the API.
Is the SDK free to use?
The SDK itself is open source and free under the MIT license. However, using it requires an OpenAI API key, and OpenAI charges for API usage based on their pricing model.
What OpenAI APIs are covered?
Based on the documentation, it supports chat completions, image generation (DALL-E 3), text-to-speech, speech-to-text, embeddings, fine-tuning, file management, moderations, and model listing.
Can I customize the HTTP client?
Yes, the SDK allows you to provide a custom OkHttpClient instance for network configuration.
How do I handle API key issues?
The SDK includes a dynamic key management feature that can automatically handle invalid, expired, or banned keys, and can trigger alerts (e.g., via DingTalk, Feishu, email) when issues occur.