Practical overview
When it fits
Use LLM when building an agent-backed application in Ruby and you need a managed tool loop, a common API across providers, or concurrent tool execution.
Who it is for
- Ruby developers building agentic AI applications.
- Teams that want a shared interface across multiple model providers.
- Developers who want agents to invoke tools implemented in their own Ruby code.
Documented uses
- Build an agent that uses a selected model provider through the runtime's common API.
- Define tools that let an agent interact with application capabilities such as files or other developer-written code.
- Run independent tools concurrently or in parallel.
- Stream agent output and receive callbacks for events such as tool calls, returns, retries and turn steps.
Requirements & limits
The repository specifies an MIT license. Installation requires Ruby 3.4 or later and uses the RubyGems command `gem install llm.rb`.
- The runtime targets CRuby and requires Ruby 3.4 or later.
- The quick-start example supplies a provider key through an environment variable.
- Tools are implemented by developers as Ruby classes; the model decides when and how to call them.
- A simple IO stream receives content, while a custom LLM::Stream subclass can receive additional runtime callbacks.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install llm.rb and start a basic agent conversation
Install the Ruby runtime and use its agent interface to send a prompt to DeepSeek.
Before you start
- CRuby with Ruby 3.4 or later
- A DeepSeek API key available in the
KEYenvironment variable
Steps
Install the gem with
gem install llm.rb.In a Ruby file, require the library with
require "llm".Create a provider client with
LLM.deepseek(key: ENV["KEY"])and an agent withLLM::Agent.new(llm, stream: $stdout).Call
agent.talk "hello world"to start a conversation.
Expected outcome
A basic agent conversation is initiated, with streamed output directed to standard output.
Guide limitations
- This example uses DeepSeek; the source does not document configuration for other providers here.
- The source recommends
LLM::Agentas the default high-level interface and does not establish provider access or successful execution.
Add a file-reading tool to an agent
Define a tool that reads a requested file and make it available to an agent.
Before you start
- Ruby 3.4 or later with llm.rb installed
- A DeepSeek API key available in the
KEYenvironment variable
Steps
Define a class inheriting from
LLM::Toolwith the nameread-file, a description, and a required stringpathparameter.Implement
call(path:)to return the file contents, as in{contents: File.read(path)}.Create a DeepSeek client and initialize
LLM::Agentwithtools: [ReadFile]andstream: $stdout.Ask the agent to summarize a file, for example with
agent.talk "summarize README.md".
Expected outcome
The agent is configured with a file-reading tool that the model can call to access file contents.
Guide limitations
- The tool reads files using the Ruby process's filesystem access; the source does not describe access controls or sandboxing.
- The model decides when and how to call the tool, so the example does not guarantee that a tool call occurs.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 12 October 2026
- Original website title
- r-uby-dev/llm · Official homepage title · retained in its source language

