ruby-openai  by alexrudall

Ruby client for OpenAI API

created 5 years ago
3,134 stars

Top 15.7% on sourcepulse

GitHubView on GitHub
Project Summary

This Ruby gem provides a comprehensive client for interacting with the OpenAI API, targeting Ruby developers who want to integrate advanced AI capabilities into their applications. It offers a robust interface for leveraging models like GPT-4, DALL-E, and Whisper, enabling features such as chat, image generation, audio transcription, and more, with streamlined integration and configuration.

How It Works

The gem utilizes Faraday for HTTP requests, allowing for flexible configuration of base URIs, timeouts, and custom headers, which is beneficial for integrating with proxy services like Helicone or Azure OpenAI. It abstracts the complexities of API calls, providing a clean Ruby interface for various OpenAI endpoints, including chat completions, image generation, audio processing, and the newer Assistants API. The design emphasizes ease of use with clear configuration options and a declarative approach to defining API parameters.

Quick Start & Requirements

  • Installation: gem install ruby-openai or add gem "ruby-openai" to your Gemfile and run bundle install.
  • Prerequisites: Ruby environment. OpenAI API key required.
  • Configuration: API keys and organization IDs should be managed via environment variables (e.g., OPENAI_ACCESS_TOKEN).
  • Documentation: https://github.com/alexrudall/ruby-openai

Highlighted Details

  • Supports streaming responses for chat completions and the Responses API.
  • Includes comprehensive support for the Assistants API, including Threads, Runs, and Tool Calls.
  • Offers integrations for alternative providers like Azure OpenAI, Deepseek, Ollama, and Groq.
  • Provides utilities for token counting and detailed examples for various OpenAI features.

Maintenance & Community

The project is actively maintained, with contributions from various developers. Community engagement is encouraged via GitHub issues and pull requests.

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: Permissive MIT license allows for commercial use and integration with closed-source applications.

Limitations & Caveats

The README warns against logging errors in production environments due to potential data leakage. Running specs against the actual API without VCR can incur costs.

Health Check
Last commit

2 weeks ago

Responsiveness

1+ week

Pull Requests (30d)
5
Issues (30d)
1
Star History
86 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.