https://github.com/crmne/ruby_llm
Stop juggling AI SDKs! RubyLLM offers one delightful Ruby interface for OpenAI, Anthropic, Gemini, Bedrock, OpenRouter, DeepSeek, Ollama & compatible APIs. Chat, Vision, Audio, PDF, Images, Embeddings, Tools, Streaming & Rails integration.
https://github.com/crmne/ruby_llm
ai anthropic chatgpt claude dall-e deepseek embeddings gemini image-generation llm openai rails ruby
Last synced: 2 months ago
JSON representation
Stop juggling AI SDKs! RubyLLM offers one delightful Ruby interface for OpenAI, Anthropic, Gemini, Bedrock, OpenRouter, DeepSeek, Ollama & compatible APIs. Chat, Vision, Audio, PDF, Images, Embeddings, Tools, Streaming & Rails integration.
- Host: GitHub
- URL: https://github.com/crmne/ruby_llm
- Owner: crmne
- License: mit
- Created: 2025-01-30T08:58:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-07T14:21:48.000Z (about 1 year ago)
- Last Synced: 2025-05-07T14:51:12.087Z (about 1 year ago)
- Topics: ai, anthropic, chatgpt, claude, dall-e, deepseek, embeddings, gemini, image-generation, llm, openai, rails, ruby
- Language: Ruby
- Homepage: https://rubyllm.com/
- Size: 35.4 MB
- Stars: 2,164
- Watchers: 19
- Forks: 106
- Open Issues: 51
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-opensource-ai - ruby_llm - One beautiful Ruby API for OpenAI, Anthropic, Gemini, Bedrock, Azure, OpenRouter, DeepSeek, Ollama, and 15+ providers. Agents, Chat, Vision, Audio, PDF, Images, Embeddings, Tools, Streaming and Rails integration. MIT licensed.  (5. Retrieval-Augmented Generation (RAG) & Knowledge)
- awesome-ChatGPT-repositories - ruby_llm - A delightful Ruby way to work with AI. No configuration madness, no complex callbacks, no handler hell – just beautiful, expressive Ruby code. (NLP)
- awesome-ruby-ai - ruby_llm - One beautiful Ruby API for GPT, Claude, Gemini, and more. (Open Source / API Libraries)
- awesome-openclaw-skills - crmne/ruby_llm
- awesome-open-source-ai-tools - crmne/ruby_llm - Stop juggling AI SDKs! RubyLLM offers one delightful Ruby interface for OpenAI, Anthropic, Gemini, Bedrock, OpenRoute... (Video & Animation)
README

One *beautiful* Ruby API for GPT, Claude, Gemini, and more.
Battle tested at [
](https://chatwithwork.com) — *Your AI coworker*
[](https://badge.fury.io/rb/ruby_llm)
[](https://github.com/rubocop/rubocop)
[](https://rubygems.org/gems/ruby_llm)
[](https://codecov.io/gh/crmne/ruby_llm)
> [!NOTE]
> Using RubyLLM? [Share your story](https://tally.so/r/3Na02p)! Takes 5 minutes.
---
Build chatbots, AI agents, RAG applications. Works with OpenAI, xAI, Anthropic, Google, AWS, local models, and any OpenAI-compatible API.
## From zero to AI chat app in under two minutes
https://github.com/user-attachments/assets/65422091-9338-47da-a303-92b918bd1345
## Why RubyLLM?
Every AI provider ships their own bloated client. Different APIs. Different response formats. Different conventions. It's exhausting.
RubyLLM gives you one beautiful API for all of them. Same interface whether you're using GPT, Claude, or your local Ollama. Just three dependencies: Faraday, Zeitwerk, and Marcel. That's it.
## Show me the code
```ruby
# Just ask questions
chat = RubyLLM.chat
chat.ask "What's the best way to learn Ruby?"
```
```ruby
# Analyze any file type
chat.ask "What's in this image?", with: "ruby_conf.jpg"
chat.ask "What's happening in this video?", with: "video.mp4"
chat.ask "Describe this meeting", with: "meeting.wav"
chat.ask "Summarize this document", with: "contract.pdf"
chat.ask "Explain this code", with: "app.rb"
```
```ruby
# Multiple files at once
chat.ask "Analyze these files", with: ["diagram.png", "report.pdf", "notes.txt"]
```
```ruby
# Stream responses
chat.ask "Tell me a story about Ruby" do |chunk|
print chunk.content
end
```
```ruby
# Generate images
RubyLLM.paint "a sunset over mountains in watercolor style"
```
```ruby
# Create embeddings
RubyLLM.embed "Ruby is elegant and expressive"
```
```ruby
# Transcribe audio to text
RubyLLM.transcribe "meeting.wav"
```
```ruby
# Moderate content for safety
RubyLLM.moderate "Check if this text is safe"
```
```ruby
# Let AI use your code
class Weather < RubyLLM::Tool
description "Get current weather"
param :latitude
param :longitude
def execute(latitude:, longitude:)
url = "https://api.open-meteo.com/v1/forecast?latitude=#{latitude}&longitude=#{longitude}¤t=temperature_2m,wind_speed_10m"
JSON.parse(Faraday.get(url).body)
end
end
chat.with_tool(Weather).ask "What's the weather in Berlin?"
```
```ruby
# Define an agent with instructions + tools
class WeatherAssistant < RubyLLM::Agent
model "gpt-5-nano"
instructions "Be concise and always use tools for weather."
tools Weather
end
WeatherAssistant.new.ask "What's the weather in Berlin?"
```
```ruby
# Get structured output
class ProductSchema < RubyLLM::Schema
string :name
number :price
array :features do
string
end
end
response = chat.with_schema(ProductSchema).ask "Analyze this product", with: "product.txt"
```
## Features
* **Chat:** Conversational AI with `RubyLLM.chat`
* **Vision:** Analyze images and videos
* **Audio:** Transcribe and understand speech with `RubyLLM.transcribe`
* **Documents:** Extract from PDFs, CSVs, JSON, any file type
* **Image generation:** Create images with `RubyLLM.paint`
* **Embeddings:** Generate embeddings with `RubyLLM.embed`
* **Moderation:** Content safety with `RubyLLM.moderate`
* **Tools:** Let AI call your Ruby methods
* **Agents:** Reusable assistants with `RubyLLM::Agent`
* **Structured output:** JSON schemas that just work
* **Streaming:** Real-time responses with blocks
* **Rails:** ActiveRecord integration with `acts_as_chat`
* **Async:** Fiber-based concurrency
* **Model registry:** 800+ models with capability detection and pricing
* **Extended thinking:** Control, view, and persist model deliberation
* **Providers:** OpenAI, xAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, and any OpenAI-compatible API
## Installation
Add to your Gemfile:
```ruby
gem 'ruby_llm'
```
Then `bundle install`.
Configure your API keys:
```ruby
# config/initializers/ruby_llm.rb
RubyLLM.configure do |config|
config.openai_api_key = ENV['OPENAI_API_KEY']
end
```
## Rails
```bash
# Install Rails Integration
bin/rails generate ruby_llm:install
bin/rails db:migrate
bin/rails ruby_llm:load_models # v1.13+
# Add Chat UI (optional)
bin/rails generate ruby_llm:chat_ui
```
```ruby
class Chat < ApplicationRecord
acts_as_chat
end
chat = Chat.create! model: "claude-sonnet-4"
chat.ask "What's in this file?", with: "report.pdf"
```
Visit `http://localhost:3000/chats` for a ready-to-use chat interface!
## Documentation
[rubyllm.com](https://rubyllm.com)
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md).
## License
Released under the MIT License.