Module: RubyLLM::Providers::XAI::Models

Included in:
ChatCompletions, Responses
Defined in:
lib/ruby_llm/providers/xai/models.rb

Overview

Models metadata for xAI list models. The list endpoint omits the model-less TTS and STT services, so those are appended under the grok-tts and grok-stt names from xAI's model catalog.

Constant Summary collapse

AUDIO_MODELS =
{
  'grok-tts' => {
    name: 'Grok TTS',
    modalities: { input: ['text'], output: ['audio'] },
    capabilities: []
  },
  'grok-stt' => {
    name: 'Grok STT',
    modalities: { input: ['audio'], output: ['text'] },
    capabilities: ['transcription']
  }
}.freeze

Class Method Summary collapse

Class Method Details

.audio_models(slug) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ruby_llm/providers/xai/models.rb', line 42

def audio_models(slug)
  AUDIO_MODELS.map do |model_id, info|
    Model.new(
      id: model_id,
      name: info[:name],
      provider: slug,
      family: 'grok',
      modalities: info[:modalities],
      capabilities: info[:capabilities],
      pricing: {},
      metadata: {}
    )
  end
end

.parse_list_models_response(response, slug) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ruby_llm/providers/xai/models.rb', line 25

def parse_list_models_response(response, slug)
  Array(response.body['data']).map do |model_data|
    model_id = model_data['id']

    Model.new(
      id: model_id,
      name: model_id,
      provider: slug,
      created_at: model_data['created'] ? Time.at(model_data['created']) : nil,
      metadata: {
        object: model_data['object'],
        owned_by: model_data['owned_by']
      }.compact
    )
  end + audio_models(slug)
end