Module: RubyLLM::Providers::OpenAI::Models

Included in:
RubyLLM::Providers::OpenAI
Defined in:
lib/ruby_llm/providers/openai/models.rb

Overview

Models methods of the OpenAI API integration

Class Method Summary collapse

Class Method Details

.models_urlObject



10
11
12
# File 'lib/ruby_llm/providers/openai/models.rb', line 10

def models_url
  'models'
end

.parse_list_models_response(response, slug, capabilities) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby_llm/providers/openai/models.rb', line 14

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_id,
      provider: slug,
      created_at: model_data['created'] ? Time.at(model_data['created']) : nil,
      context_window: capabilities.context_window_for(model_id),
      max_output_tokens: capabilities.max_tokens_for(model_id),
      capabilities: capabilities.critical_capabilities_for(model_id),
      pricing: capabilities.pricing_for(model_id),
      metadata: {
        object: model_data['object'],
        owned_by: model_data['owned_by']
      }
    )
  end
end