Basic checks
What's broken?
Trying to use a model that does not exist in the registry does not seem to work as documented when using the Rails integration with custom names for the RubyLLM model classes.
How to reproduce
I created a test repo with a rake task that shows
RubyLLM.chat working with a model that requires assume_model_exists to be set
Llm::Chat (Rails model) working with a known model
Llm::Chat failing with an unknown model
Expected behavior
All three chats succeed.
What actually happened
$ OPENROUTER_API_KEY=sk-or-v1-asdf1234 bin/rake test_ruby_llm
Testing RubyLLM.chat with unknown model
Hi there! How can I help you today?
Testing Llm::Chat with known model
Hi there! How can I help you today?
Testing Llm::Chat with unknown model
rake aborted!
RubyLLM::ModelNotFoundError: Unknown model: anthropic/claude-opus-4.5 for provider: openrouter (RubyLLM::ModelNotFoundError)
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/models.rb:222:in `find_with_provider'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/models.rb:178:in `find'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/models.rb:84:in `method_missing'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/models.rb:74:in `resolve'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/chat.rb:60:in `with_model'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/chat.rb:18:in `initialize'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm.rb:47:in `new'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm.rb:47:in `chat'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/active_record/chat_methods.rb:80:in `to_llm'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/active_record/chat_methods.rb:198:in `complete'
/Users/joseph/.rvm/gems/ruby-3.3.5/gems/ruby_llm-1.9.1/lib/ruby_llm/active_record/chat_methods.rb:192:in `ask'
/Users/joseph/projects/ruby_llm_test/lib/tasks/test_ruby_llm.rake:26:in `block in <main>'
Environment
- Ruby version: ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin24]
- RubyLLM version: 1.9.1
- Provider: OpenRouter
- OS: Mac OS
Fixed by #564
Basic checks
What's broken?
Trying to use a model that does not exist in the registry does not seem to work as documented when using the Rails integration with custom names for the RubyLLM model classes.
How to reproduce
I created a test repo with a rake task that shows
RubyLLM.chatworking with a model that requiresassume_model_existsto be setLlm::Chat(Rails model) working with a known modelLlm::Chatfailing with an unknown modelExpected behavior
All three chats succeed.
What actually happened
Environment
Fixed by #564