Official Ruby SDK for the OpenAI API
Top 87.9% on SourcePulse
This Ruby SDK provides a convenient interface to the OpenAI REST API, targeting Ruby developers building applications that leverage AI models for tasks like text generation, image editing, and webhook processing. It simplifies API interactions, offering features like streaming responses, automatic pagination, and robust error handling, enabling efficient integration of OpenAI's capabilities into Ruby projects.
How It Works
The library utilizes Ruby's standard net/http
for HTTP transport, enhanced with connection pooling via the connection_pool
gem for efficient resource management. It supports Server-Sent Events (SSE) for streaming responses and provides auto-paginating iterators for list endpoints, abstracting away manual page management. For structured outputs and function calling, it includes helper classes like OpenAI::BaseModel
and OpenAI::ArrayOf
to define and parse JSON schemas.
Quick Start & Requirements
gem "openai", "~> 0.16.0"
OPENAI_API_KEY
environment variable.Highlighted Details
Pathname
, StringIO
, or raw content.Maintenance & Community
The project follows SemVer conventions. As it is in major version 0, APIs may change. Contributions are welcome via the contributing documentation.
Licensing & Compatibility
The library is available under the MIT license, permitting commercial use and integration with closed-source applications.
Limitations & Caveats
The library is in major version 0, indicating potential for breaking changes. Client instances are not fork-safe if HTTP requests are in flight during a fork.
1 day ago
1 day