module RubyLLM

RubyLLM is a Ruby interface to large language models. One API for OpenAI, Anthropic, Google, AWS, and every other major provider. These pages document every public class and method; the guides at rubyllm.com show how to build things with them.

RubyLLM.configure do |config|
  config.openai_api_key = ENV['OPENAI_API_KEY']
end

chat = RubyLLM.chat
chat.ask "What is the capital of France?"

Start here

Chat is the heart of the library. ::chat starts a conversation, and Chat#ask sends a message and returns a Message. Everything else builds on this: attachments, streaming, structured output, and tool calls.

Tool gives the model abilities. Subclass it, declare parameters, implement execute, and pass it to Chat#with_tools. Agent packages a configured chat (model, instructions, tools, schema) into a reusable class.

Beyond chat

Rails

acts_as_chat persists conversations to Active Record, with siblings for messages, tool calls, models, and batches. See ActiveRecord::ActsAs.

Configuration and models

Configuration holds global settings, set through ::configure. Context scopes overrides to a group of calls. Models finds, filters, and prices every known model.

Provider errors raise subclasses of Error, one per HTTP status family.