Repolode
crmne

crmne/ruby_llm

The Ruby AI framework for building LLM features with chat, tools, agents, embeddings, and Rails integration through one API.

Stars
4,497
Forks
534
Open issues
27
Last commit
4 hours ago

What is it?

RubyLLM is a Ruby framework for building AI features in applications. It provides one consistent API across 23 model providers, including OpenAI, Anthropic, Gemini, Ollama, and OpenRouter, and any OpenAI-compatible endpoint, so switching between hosted and local models does not require rewriting application code.

Beyond basic chat, the framework covers tool calling where Ruby methods become callable by the model, reusable agents, structured output defined with Ruby schemas, streaming, embeddings, image and video generation, transcription, speech synthesis, and OCR. It also includes an evaluation system that runs datasets through RSpec, Minitest, or Rake, along with MCP server connections, prompt caching, fallbacks, and per-attempt cost tracking.

For Rails applications, RubyLLM offers Active Record persistence for conversations, Active Storage attachments, Hotwire streaming, and generators that produce a working chat interface.

Key features

  • 01Unified API across 23 providers, including local models through Ollama and OpenAI-compatible endpoints.
  • 02Tool calling that exposes Ruby methods to the model, with optional human approval.
  • 03Reusable agents and an agentic loop that can be driven step by step.
  • 04Structured output from Ruby schemas, with responses parsed into Ruby objects.
  • 05Evaluations run from Ruby, RSpec, Minitest, or Rake.
  • 06Rails integration with Active Record persistence, Hotwire streaming, and generators.

Use cases

  • Adding a chat assistant with saved conversation history to a Rails application.
  • Building an agent that calls internal Ruby methods to answer questions or take actions.
  • Generating embeddings and reranking search results in a retrieval pipeline.
  • Testing LLM responses against a dataset as part of an existing RSpec or Minitest suite.

Quick start

  1. 1

    Install the gem with Bundler

    bundle add ruby_llm --version 2.1.1
  2. 2

    Configure a provider API key in your script

  3. 3

    Ask a question with one line of code

    RubyLLM.chat.ask "What's the best way to learn Ruby?"

Things to know

  • Requires an API key from at least one model provider.
  • Evaluations and some features such as code execution are only on the main branch, not the stable release.

In collections

Topics

FAQ

What is ruby_llm?
The Ruby AI framework for building LLM features with chat, tools, agents, embeddings, and Rails integration through one API. RubyLLM is a Ruby framework for building AI features in applications. It provides one consistent API across 23 model providers, including OpenAI, Anthropic, Gemini, Ollama, and OpenRouter, and any OpenAI-compatible endpoint, so switching between hosted and local models does not require rewriting application code.
Is ruby_llm free to use? What license does it have?
ruby_llm is open source under the MIT license. Check the license terms before using it in commercial products.
Is ruby_llm still maintained?
Actively maintained. The last commit to ruby_llm was on Nov 7, 2026.
What can I use ruby_llm for?
Adding a chat assistant with saved conversation history to a Rails application. Building an agent that calls internal Ruby methods to answer questions or take actions. Generating embeddings and reranking search results in a retrieval pipeline. Testing LLM responses against a dataset as part of an existing RSpec or Minitest suite.
How do I install ruby_llm?
Install the gem with Bundler: bundle add ruby_llm --version 2.1.1 Configure a provider API key in your script Ask a question with one line of code: RubyLLM.chat.ask "What's the best way to learn Ruby?"
Where can I get ruby_llm?
The source code and installation instructions are on GitHub: https://github.com/crmne/ruby_llm

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects