RubyLLM exposes one Ruby API for chat, tools, agents, media, embeddings, and evaluations across many model providers. Rails apps get persistence, streaming, and generators.
Overview
RubyLLM is a Ruby library for building AI features with a single interface across many hosted and local model providers, including OpenAI-compatible endpoints. Conversations support streaming, attachments, structured output schemas, extended thinking, citations, prompt caching, compaction, token counting, fallbacks, and cancellation.
Tool calling, provider-side tools, MCP connectors, human approval gates, reusable agent classes, prompt templates, workflows, evaluations, and judgments are part of the same stack. Separate APIs cover image and video generation, transcription, speech synthesis, OCR, embeddings, reranking, moderation, file uploads, and batch jobs.
Rails integration adds Active Record chat models, Active Storage for attachments, Hotwire streaming, background jobs, cost tracking per attempt, OpenTelemetry instrumentation, and generators for agents, tools, schemas, prompts, skills, sandboxes, MCP servers, and evals. Optional sandboxed code execution runs Ruby, Python, JavaScript, or shell on your servers with skills and file stores for long outputs.
The gem ships documentation, a model registry for capabilities and pricing, a packaged skill for coding assistants, and migration notes from ruby-openai and langchainrb. Provider gems can follow the same scaffolding pattern for custom endpoints.
Key features
- Unified chat API across providers
- Tools, agents, and MCP support
- Structured output and streaming
- Embeddings, media, and moderation APIs
- Rails persistence and Hotwire streaming
- Evaluations and judgment helpers
- Sandboxed multi-language code execution
- OpenTelemetry and cost tracking
Use cases
- Multi-provider LLM features in Ruby
- Rails chat and agent applications
- RAG and tool-using assistants
- Agent evaluation in test suites