Ruby Llm
One beautiful Ruby API for OpenAI, Anthropic, Gemini, Bedrock, Azure, OpenRouter, DeepSeek, Ollama, VertexAI, Perplexity, Mistral, xAI, GPUStack & OpenAI compatible APIs. Agents, Chat, Vision, Audio, PDF, Images, Embeddings, Tools, Streaming & Rails integration.
Last verified:
What is Ruby Llm?
Ruby Llm is a Ruby gem that provides one beautiful, Ruby-like API for accessing multiple AI models including GPT, Claude, Gemini, and more. It eliminates the frustration of juggling incompatible APIs from different AI providers by offering a unified interface with consistent response formats. The gem enables developers to easily build chatbots, AI agents, RAG applications, and content generators with clean, expressive Ruby code.
Ruby Llm pricing
Pricing model: Freemium
RubyLLM itself is free and open-source under the MIT License. The gem has no subscription fees or paid plans. However, you must pay usage-based fees directly to the AI providers you use (OpenAI, Anthropic, Gemini, etc.). The model registry includes pricing information showing costs per million tokens for input and output. You only pay for the API calls you make to each provider. Costs vary by provider and model - for example, input and output prices are listed per million tokens in the model registry. Cache read and cache write tokens may also have separate pricing for supported models.
Ruby Llm pros
- One unified API for all major AI providers
- Minimal dependencies - only Faraday, Zeitwerk, and Marcel
- Ruby-like, idiomatic API that feels natural
- Supports 800+ models from all major providers
- Built-in Rails integration with ActiveRecord persistence
- Ready-to-use chat UI generator for Rails
- Vision capabilities for images, videos, and documents
- Audio transcription with RubyLLM.transcribe
- Image generation with RubyLLM.paint
- Tool calling lets AI execute Ruby code
- Structured output with JSON schemas that just work
- Real-time streaming with idiomatic Ruby blocks
- Fiber-based async concurrency for high performance
- Model registry with pricing and capability detection
- Works with local models via Ollama and GPUStack
- Content moderation with RubyLLM.moderate
- Reusable agents via RubyLLM::Agent class
- Extended thinking support with control and persistence
Ruby Llm cons
- Requires separate API keys for each AI provider
- Only works with Ruby and Ruby on Rails
- Pay-per-use pricing from AI providers (not free)
- Local model support limited to Ollama and GPUStack
- No built-in hosting - you provide API keys
- Model registry requires refresh for new models
- Some advanced features require Rails generator setup
- Custom endpoints need manual provider configuration
Frequently asked questions about Ruby Llm
What is RubyLLM?
RubyLLM is one beautiful Ruby API for GPT, Claude, Gemini, and more. It provides a unified, Ruby-like interface to interact with modern AI models from multiple providers including OpenAI, Anthropic, Google, AWS, and local models. You can chat, generate images, create embeddings, use tools, and build AI agents all with clean, expressive code that feels like Ruby.
How do I install RubyLLM?
Add ruby_llm to your Gemfile with 'gem ruby_llm' then run 'bundle install'. For Rails applications, run 'bin/rails generate ruby_llm:install' to create Chat and Message models with ActiveRecord persistence, and optionally 'bin/rails generate ruby_llm:chat_ui' to add a ready-to-use chat interface at http://localhost:3000/chats.
Which AI providers does RubyLLM support?
RubyLLM supports OpenAI, xAI, Anthropic, Gemini, VertexAI, Bedrock, DeepSeek, Mistral, Ollama, OpenRouter, Perplexity, GPUStack, and any OpenAI-compatible API. This includes 800+ models total with automatic capability detection and pricing information in the model registry.
How do I configure API keys?
Configure API keys in config/initializers/ruby_llm.rb using RubyLLM.configure block. Use environment variables for security: config.openai_api_key = ENV.fetch('OPENAI_API_KEY', nil). You only need to configure keys for providers you actually plan to use. See the Configuration Guide for all options including setting defaults and connecting to custom endpoints.
How does Rails integration work?
RubyLLM integrates deeply with Rails through ActiveRecord mixins. Run 'bin/rails generate ruby_llm:install' to create Chat and Message models with database-backed conversations. Add 'acts_as_chat' to your model to enable AI capabilities. The optional chat_ui generator creates controllers, views with Turbo streaming for real-time updates, background jobs, and routes. Visit http://localhost:3000/chats for a ready-to-use chat interface.
Is RubyLLM free to use?
RubyLLM itself is completely free and open-source under the MIT License with no subscription fees. However, you must pay usage-based fees directly to the AI providers you use (OpenAI, Anthropic, Gemini, etc.). The gem includes a model registry with pricing information showing costs per million tokens so you can calculate expenses based on your token usage.