RubyLLM is a Ruby gem that provides a unified interface for interacting with AI models. When configured with Respan, it enables logging, analytics, fallbacks, and access to 250+ models through a single API key.
Switch between OpenAI, Anthropic, Google, and other providers by changing the model parameter. The integration supports streaming responses and Rails compatibility via initializer configuration.
Add ruby_llm to your Gemfile and run bundle install. Configure RubyLLM to point openai_api_base to https://api.keywordsai.co/api/ and provide your Respan API key.
Make requests using standard RubyLLM syntax. All requests are automatically logged to the Respan platform for analytics. Streaming is supported via block syntax.
ruby
# config/initializers/ruby_llm.rb
RubyLLM.configure do |config|
config.openai_api_base = "https://api.keywordsai.co/api/"
config.openai_api_key = ENV["RESPAN_API_KEY"]
end
# Usage
chat = RubyLLM.chat(model: "gpt-4o-mini")
response = chat.ask("What is the meaning of life?")