module RubyLLM::ActiveRecord::ModelMethods
ModelMethods is mixed into the model registry class by acts_as_model. Each record stores one entry of the RubyLLM model registry and answers the same capability and pricing queries as RubyLLM::Model. Those queries delegate to the Model object returned by to_llm.
class Model < ApplicationRecord acts_as_model end Model.refresh! model = Model.find_by(model_id: 'claude-sonnet-4-6') model.supports?(:vision) # => true
Public Instance Methods
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 152 delegate :supports?, :price, :type, :provider_class, :label, :cost_for, to: :to_llm
Builds a Cost for tokens using this model’s pricing. See Model#cost_for.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 140
Returns the provider display name and model name combined, e.g. "OpenAI - GPT-5.4". See Model#label.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 126
Returns the standard text-token price for kind (:input, :output, :cache_read, or :cache_write) in USD per million tokens, or nil if unknown. See Model#price.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 134
Returns the Provider class registered for this model’s provider, or nil if none is registered. See Model#provider_class.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 95
Returns whether the model supports capability, given as a String or Symbol. See Model#supports?.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 108
Returns whether the model supports tool calling. Same as #function_calling?.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 102
Returns whether the model accepts image input. See Model#supports_vision?.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 77 def to_llm RubyLLM::Model.new( id: model_id, name: name, provider: provider, family: family, created_at: model_created_at, context_window: context_window, max_output_tokens: max_output_tokens, knowledge_cutoff: knowledge_cutoff, modalities: modalities&.deep_symbolize_keys || {}, capabilities: capabilities, pricing: pricing&.deep_symbolize_keys || {}, metadata: metadata&.deep_symbolize_keys || {} ) end
Returns a RubyLLM::Model built from this record’s attributes.
Source
# File lib/ruby_llm/active_record/model_methods.rb, line 114
Returns the model’s primary function, such as "chat" or "embedding". See Model#type.