ruby_llm  by crmne

Ruby SDK for unified AI model access

created 6 months ago
2,630 stars

Top 18.3% on sourcepulse

GitHubView on GitHub
Project Summary

RubyLLM provides a unified Ruby interface for interacting with various large language models and AI services, abstracting away the complexities of individual provider SDKs. It targets Ruby developers seeking a consistent and idiomatic way to integrate AI capabilities like chat, image generation, embeddings, and tool usage into their applications, simplifying multi-provider workflows and reducing dependency bloat.

How It Works

The library employs a strategy of creating a single, consistent API layer over diverse AI provider clients. It uses a modular design where each provider is implemented as a distinct adapter. This approach allows developers to switch between providers with minimal code changes, as the core RubyLLM.chat interface and response formats remain constant. Key features like streaming, tool usage, and multi-modal inputs (vision, audio, PDF) are handled through this unified abstraction.

Quick Start & Requirements

  • Install via RubyGems: gem install ruby_llm or add gem 'ruby_llm' to your Gemfile and run bundle install.
  • Requires Ruby. API keys for desired providers (OpenAI, Anthropic, Gemini, etc.) must be configured, preferably via environment variables.
  • Official documentation is available for installation, configuration, and guides on specific features: https://github.com/crmne/ruby_llm#readme

Highlighted Details

  • Supports a wide range of providers including OpenAI, Anthropic, Gemini, Bedrock, OpenRouter, DeepSeek, and Ollama.
  • Offers unified interfaces for chat, vision, audio transcription, PDF analysis, image generation, and text embeddings.
  • Features robust tool (function calling) support for enabling AI to execute custom Ruby code.
  • Includes seamless Rails integration with acts_as_chat and acts_as_message for persistent conversation history.
  • Handles real-time streaming responses using idiomatic Ruby blocks.

Maintenance & Community

The project is actively maintained by crmne. Contribution guidelines are available in CONTRIBUTING.md.

Licensing & Compatibility

Released under the MIT License. This permissive license allows for commercial use and integration into closed-source applications.

Limitations & Caveats

While the library aims for broad compatibility, specific model capabilities (e.g., advanced vision or audio features) may vary depending on the underlying AI provider's implementation. Users must manage individual provider API keys and potential rate limits.

Health Check
Last commit

1 day ago

Responsiveness

1 day

Pull Requests (30d)
41
Issues (30d)
25
Star History
517 stars in the last 90 days

Explore Similar Projects

Starred by Peter Norvig Peter Norvig(Author of Artificial Intelligence: A Modern Approach; Research Director at Google), Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), and
2 more.

aisuite by andrewyng

0.2%
12k
Unified interface for multiple generative AI providers
created 1 year ago
updated 3 days ago
Feedback? Help us improve.