Installation & Configuration

RubyLLM is a Ruby gem that gives you a single, elegant interface to work with multiple AI providers — OpenAI, Anthropic, Google Gemini, and more. Instead of learning a different SDK for each provider, you learn one API and swap models freely.

Installing the Gem

In any Ruby project, add RubyLLM to your Gemfile:

gem "ruby_llm"

Then run bundle install. That’s it — no provider-specific gems needed.

Configuration

Open setup.rb in the editor. RubyLLM needs API keys to talk to providers. Complete the configure block:

setup.rb
RubyLLM.configure do |config|
# Add your API key configuration here
config.openai_api_key = ENV.fetch("OPENAI_API_KEY", nil)
config.anthropic_api_key = ENV.fetch("ANTHROPIC_API_KEY", nil)
config.gemini_api_key = ENV.fetch("GEMINI_API_KEY", nil)
end

You only need keys for providers you plan to use:

ProviderConfig keyModels
OpenAIconfig.openai_api_keyGPT-4o, o1, DALL-E
Anthropicconfig.anthropic_api_keyClaude Sonnet, Opus, Haiku
Googleconfig.gemini_api_keyGemini Pro, Flash

Run the script to verify:

Terminal window
$ ruby setup.rb

What Makes RubyLLM Different?

  • One interface, many providers — switch from GPT to Claude by changing a model name
  • Conversation history is automatic — no manual message array management
  • Tools are just Ruby classes — no JSON schema boilerplate
  • Streaming, embeddings, and image generation — all built in
Built by <a href="https://chamoylabs.com">Chamoy Labs</a> based on <a href="https://rubyllm.com/">RubyLLM</a> by <a href="https://paolino.me/">Carmine Paolino</a>
Files
Preparing Environment
  • Preparing Ruby runtime