module RubyLLM::Providers::Anthropic::Models
Public Instance Methods
# File lib/ruby_llm/providers/anthropic/models.rb, line 46 def extract_cache_creation_tokens(data) direct = data.dig('message', 'usage', 'cache_creation_input_tokens') || data.dig('usage', 'cache_creation_input_tokens') return direct if direct breakdown = data.dig('message', 'usage', 'cache_creation') || data.dig('usage', 'cache_creation') return unless breakdown.is_a?(Hash) breakdown.values.compact.sum end
Source
# File lib/ruby_llm/providers/anthropic/models.rb, line 42 def extract_cached_tokens(data) data.dig('message', 'usage', 'cache_read_input_tokens') || data.dig('usage', 'cache_read_input_tokens') end
Source
# File lib/ruby_llm/providers/anthropic/models.rb, line 34 def extract_input_tokens(data) data.dig('message', 'usage', 'input_tokens') end
Source
# File lib/ruby_llm/providers/anthropic/models.rb, line 30 def extract_model_id(data) data.dig('message', 'model') end
Source
# File lib/ruby_llm/providers/anthropic/models.rb, line 38 def extract_output_tokens(data) data.dig('message', 'usage', 'output_tokens') || data.dig('usage', 'output_tokens') end
Source
# File lib/ruby_llm/providers/anthropic/models.rb, line 12 def models_url 'v1/models' end
# File lib/ruby_llm/providers/anthropic/models.rb, line 16 def parse_list_models_response(response, slug, _capabilities) Array(response.body['data']).map do |model_data| model_id = model_data['id'] Model::Info.new( id: model_id, name: model_data['display_name'] || model_id, provider: slug, created_at: Time.parse(model_data['created_at']), metadata: {} ) end end