ruby_llm is a free, open source ai development platforms project written in Ruby and released under MIT. It has 4,490 GitHub stars, 530 forks and 7 open issues, and was last pushed 2 hours ago. On this registry it ranks #113 of 155 tracked projects in AI Development Platforms, with 5 head-to-head comparisons available. It gained 67 stars over the last 30 tracked days.

What is ruby_llm?

RubyLLM is the Ruby-native AI framework that gives Ruby and Rails applications chats, agents, tools, images, audio, and video through one consistent API spanning 17 providers.

What it is

RubyLLM is an MIT-licensed Ruby gem, published as ruby_llm on RubyGems, that wraps large language model and multimodal providers behind a single Ruby interface. It is catalogued under AI & Machine Learning / AI Development Platforms, and it lives squarely in the Ruby and Rails ecosystem: the same object graph is reachable from a plain Ruby script or from inside a Rails application. The framework covers chat completions, agent definitions, tool calling, structured output, embeddings, reranking, image generation, video generation, speech synthesis, transcription, OCR, and moderation, and it adds usage tracking and Rails integration as built-in concerns rather than add-ons.

The concrete problem it solves is provider lock-in and modality sprawl. A team that talks to OpenAI, Anthropic, Gemini, or a local Ollama instance through each vendor's own client writes integration code that has to be rewritten whenever the deployment moves between a hosted and a local model, or between one vendor and another. RubyLLM replaces that hand-assembled stack with one API surface, and it also folds in the separate one-off work a team would otherwise do for embeddings, transcription, OCR, and image generation, so those tasks arrive as RubyLLM.embed, RubyLLM.transcribe, RubyLLM.ocr, and RubyLLM.paint instead of as four unrelated dependencies.

Key capabilities

  • One Ruby API across 17 providers, including OpenAI, Anthropic, Gemini, and Ollama, plus the ability to connect any OpenAI-compatible endpoint.
  • Chat through RubyLLM.chat.ask, with streaming available by passing a block and reading chunk.content per chunk.
  • Multimodal file input via the with: argument, accepting "ruby_conf.jpg", "video.mp4", "meeting.wav", "contract.pdf", and "app.rb", and accepting an array such as ["diagram.png", "report.pdf", "notes.txt"].
  • Tool calling by subclassing RubyLLM::Tool, declaring description and execute, then attaching the class with chat.with_tools(Weather).
  • Agent definitions through RubyLLM::Agent, declaring model, instructions, and tools, then invoking the agent with .ask.
  • Structured output through a Schematist::Schema subclass used with chat.with_schema(ProductSchema), reading the result from response.parsed.
  • Media and document operations: RubyLLM.paint with image.save, RubyLLM.animate with video.save, RubyLLM.rerank with a model such as "rerank-v3.5", RubyLLM.speak, and RubyLLM.moderate(...).flagged?.

Who uses it and how

  • Rails teams adding AI features directly to an existing application, using the built-in Rails integration and usage tracking rather than building a separate service.
  • Applications that shift between hosted providers and local models served by Ollama, keeping the same call sites because the provider is a configuration concern.
  • Privacy-sensitive deployments, reflected in the README's note that it is battle tested at chatwithwork.com, described there as fully private work AI.
  • Retrieval and document workflows that combine RubyLLM.embed for vectors with RubyLLM.rerank for ordering results, and RubyLLM.ocr for turning a PDF into markdown.
  • Agent workflows that let the model call real application code, as in the weather example where a tool calls the Open-Meteo HTTP API.

Getting started

Install the ruby_llm gem and follow the Getting Started guide at rubyllm.com, which covers configuring the providers to try; the published examples target version 2.0.0, and separate 1.x documentation is maintained at rubyllm.com/v1/.

How it compares

No paid products and no peer Ruby frameworks are named in the facts for this entry, so on the evidence here RubyLLM stands alone in this registry. Its comparative axis is provider coverage rather than vendor substitution: 17 providers behind one API, hosted or local, with an OpenAI-compatible endpoint as a fallback path.

When to use it — and when not to

Choose it when the application is written in Ruby or Rails and the goal is one interface across several providers, since the work it removes is the per-provider integration code. Do not choose it for a non-Ruby stack, and do not expect a hosted service: this is a gem called from your own application, so provider credentials and configuration remain the adopter's responsibility. The main weakness visible in the facts is documentation sprawl, with the README excerpt itself cut off mid-sentence and guidance split between the 2.0.0 examples and the separate 1.x docs, so budget time on rubyllm.com before committing.

project readme (upstream, from github) — read inline

Build AI features the Ruby way

RubyLLM is the Ruby-native AI framework. Work with models, tools, and agents through one consistent API, in plain Ruby or Rails.

Website · Getting Started · What's New in 2.0

Battle tested at Chat with Work - Fully private work AI

Gem Version Ruby Style Guide Gem Downloads codecov

crmne%2Fruby_llm | Trendshift

[!NOTE] Using RubyLLM? Share your story! Takes 5 minutes.


17 providers. One Ruby API.

Build with the models you want. Move between hosted and local providers without rewriting your application, or connect an OpenAI-compatible endpoint.

Browse models and pricing · Connect a provider

Start with one line. Add files, tools, and agents

These examples use 2.0.0. Follow Getting Started to install it and configure the providers you want to try. For 1.x, use the 1.x docs.

# Just ask
RubyLLM.chat.ask "What's the best way to learn Ruby?"
# Ask about files with a model that supports their input types
chat = RubyLLM.chat(model: "gemini-3.7-flash")
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"
# Multiple files at once
chat.ask "Analyze these files", with: ["diagram.png", "report.pdf", "notes.txt"]
# Stream responses
chat.ask "Tell me a story about Ruby" do |chunk|
  print chunk.content
end
# Generate images
image = RubyLLM.paint "a sunset over mountains in watercolor style"
image.save "sunset.png"
# Generate videos
video = RubyLLM.animate "a paper boat sailing down a rainy gutter"
video.save "paper_boat.mp4"
# Create embeddings
embedding = RubyLLM.embed "Ruby is elegant and expressive"
embedding.vectors
# Rank search results
documents = ["Reset your password in Settings.", "Invoices arrive by email."]
ranked = RubyLLM.rerank("How do I reset my password?", documents, model: "rerank-v3.5")
ranked.results.first.document
# Transcribe audio to text
transcript = RubyLLM.transcribe "meeting.wav"
puts transcript.text
# Turn text into speech
speech = RubyLLM.speak "Hello, welcome to RubyLLM!"
speech.save "welcome.mp3"
# Extract document text as markdown
document = RubyLLM.ocr "contract.pdf"
puts document.markdown
# Check whether a moderation model flags content
RubyLLM.moderate("Some user-generated content").flagged?
# Let AI use your code
class Weather < RubyLLM::Tool
  description "Get current weather"

  def execute(latitude:, longitude:)
    url = "https://api.open-meteo.com/v1/forecast?latitude=#{latitude}&longitude=#{longitude}&current=temperature_2m,wind_speed_10m"
    JSON.parse(Faraday.get(url).body)
  end
end

chat.with_tools(Weather).ask "What's the weather in Berlin?"
# Define an agent with instructions + tools
class WeatherAssistant < RubyLLM::Agent
  model "gpt-5.6-luna"
  instructions "Be concise and always use tools for weather."
  tools Weather
end

WeatherAssistant.new.ask "What's the weather in Berlin?"
# Get structured output
class ProductSchema < Schematist::Schema
  string :name
  number :price
  array :features do
    string
  end
end

response = chat.with_schema(ProductSchema).ask "Analyze this product", with: "product.txt"
response.parsed

A complete AI framework for Ruby

Agents, workflows, RAG, images, audio, and video. Built in, with usage tracking and Rails integration to bring them into your app.

  • Chat: Conversational AI with RubyLLM.chat
  • Vision: Analyze images and videos
  • Audio: Transcribe speech with RubyLLM.transcribe and generate it with RubyLLM.speak
  • Documents: Ask questions about PDFs, text files, and other supported formats
  • OCR: Turn documents into markdown with RubyLLM.ocr
  • Image generation: Create images with RubyLLM.paint
  • Video generation: Create videos with RubyLLM.animate
  • Embeddings: Generate embeddings with RubyLLM.embed
  • Reranking: Order retrieval candidates by relevance with RubyLLM.rerank
  • Moderation: Content flags, categories, and scores with RubyLLM.moderate
  • Tools: Let AI call your Ruby methods
  • Tool approval: Park a run until a human approves with requires_approval
  • The agentic loop: Drive it yourself with ask_later, step, and complete?
  • Server tools: Web search, code execution, and MCP connectors with with_server_tools
  • Agents: Reusable assistants with RubyLLM::Agent
  • Prompt templates: ERB prompts in app/prompts, rendered with RubyLLM.render_prompt
  • Workflows: Correlate multi-agent runs in your telemetry with RubyLLM.workflow
  • Structured output: Define a Ruby schema and read the result with response.parsed
  • Streaming: Real-time responses with blocks
  • Rails: Active Record persistence, Active Storage attachments, Hotwire streaming, and generators
  • Files: Upload once and reuse across chats with RubyLLM.upload
  • Prompt caching: Turn on the provider's cache with with_caching and cache_until_here
  • Fallbacks and cancellation: Retry on backup models with with_fallbacks, stop a run with cancel
  • Cost tracking: A per-attempt usage ledger behind chat.tokens and chat.cost
  • Async: Fiber-based concurrency
  • Model registry: Browse capabilities, limits, and pricing across providers
  • Extended thinking: Control, view, and persist model deliberation
  • Citations: Normalized source citations from documents, search, and grounding
  • Batches: Provider-side batch processing with provider-specific discounts via RubyLLM.batch
  • Compaction: Let providers condense long conversations with with_compaction
  • Token counting: Count a request before you send it with count_tokens
  • Providers: OpenAI, Azure, xAI, Anthropic, Gemini, VertexAI, Bedrock, Cohere, DeepSeek, Mistral, Ollama, Ollama Cloud, OpenRouter, Perplexity, GPUStack, ElevenLabs, Deepgram, and any OpenAI-compatible API

Installation

Install RubyLLM 2.0:

bundle add ruby_llm --version 2.0.0

Configure a provider in your script, or in config/initializers/ruby_llm.rb in Rails:

require 'ruby_llm'

RubyLLM.configure do |config|
  config.openai_api_key = ENV.fetch('OPENAI_API_KEY')
end

Configure the other providers used by the examples as needed: Gemini for files, xAI for video, Mistral for OCR, and Cohere for reranking. Getting Started shows each setup beside its example. If your app uses 1.16, follow the upgrade guide before deploying 2.0.

Feels at home in Rails

Save conversations with Active Record and stream replies with Hotwire. The generators give you a working chat UI. Watch the two-minute demo.

https://github.com/user-attachments/assets/65422091-9338-47da-a303-92b918bd1345

# Install Rails Integration
bin/rails generate ruby_llm:install
bin/rails db:migrate
bin/rails ruby_llm:load_models

# Add Chat UI (optional)
bin/rails generate ruby_llm:chat_ui
class Chat < ApplicationRecord
  acts_as_chat
end

chat = Chat.create! model: "gpt-5.6-luna"
chat.ask "What's in this file?", with: "report.pdf"

Start your Rails server and visit http://localhost:3000/chats to try the chat interface. See the Rails guide for persistence, streaming, and background jobs.

AI coding assistants

Give your coding assistant the RubyLLM API and documentation that match your application. From your application directory, install the skill packaged with your gem:

npx skills add "$(bundle show ruby_llm)" --skill rubyllm

Choose your coding assistant and installation scope when prompted. See AI Coding Assistants for setup and updates.

Documentation

Guides · API reference · Models · Upgrading · 1.x docs

Contributing

See CONTRIBUTING.md.

License

Released under the MIT License.

Frequently asked questions

Is ruby_llm free to use?

ruby_llm is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does ruby_llm do?

The Ruby-native AI framework. Chats, agents, tools, images, audio, and video through one consistent API, in plain Ruby or Rails.

What is ruby_llm written in?

ruby_llm is primarily written in Ruby. Its source is publicly available at https://github.com/crmne/ruby_llm, and it has 4,490 GitHub stars.