RubyLLM 1.0.0
A beautiful way to work with AI in Ruby. RubyLLM a unified interface to modern AI models from multiple providers with an elegant, Ruby-like API.
Features
- Unified API for OpenAI, Anthropic Claude, Google Gemini, and DeepSeek
- Simple conversation interface with automatic history tracking
- Consistent streaming that works the same way across all providers
- Built-in token tracking for cost management
- Tool integration with a clean, Ruby-like interface
- Rails integration with ActiveRecord persistence via
acts_as_chat
- Multimodal support for images, PDFs, and audio
- Embeddings for vector search and semantic analysis
- Image generation with DALL-E and other providers
- Comprehensive error handling with specific error types
- Minimal dependencies for a lightweight footprint
Installation
# In your Gemfile
gem 'ruby_llm'
# Or install directly
gem install ruby_llm
Quick Start
# Configure with API keys
RubyLLM.configure do |config|
config.openai_api_key = ENV['OPENAI_API_KEY']
config.anthropic_api_key = ENV['ANTHROPIC_API_KEY']
config.gemini_api_key = ENV['GEMINI_API_KEY']
end
# Start chatting
chat = RubyLLM.chat
chat.ask "What's the best way to learn Ruby?"
# Or generate an image
image = RubyLLM.paint("a sunset over mountains")
image.save("sunset.png")
# Or create embeddings
embedding = RubyLLM.embed("Ruby is a programmer's best friend")
Documentation
Full documentation is available at rubyllm.com
License
Released under the MIT License.