Class: RubyLLM::Providers::XAI

Inherits:
RubyLLM::Provider show all
Defined in:
lib/ruby_llm/providers/xai.rb,
lib/ruby_llm/providers/xai/chat.rb,
lib/ruby_llm/providers/xai/images.rb,
lib/ruby_llm/providers/xai/models.rb,
lib/ruby_llm/providers/xai/speech.rb,
lib/ruby_llm/providers/xai/videos.rb,
lib/ruby_llm/providers/xai/responses.rb,
lib/ruby_llm/providers/xai/capabilities.rb,
lib/ruby_llm/providers/xai/reported_cost.rb,
lib/ruby_llm/providers/xai/transcription.rb,
lib/ruby_llm/providers/xai/chat_completions.rb,
lib/ruby_llm/providers/xai/chat_completions/batches.rb

Overview

xAI API integration

Defined Under Namespace

Modules: Capabilities, Chat, Images, Models, ReportedCost, Speech, Transcription, Videos Classes: ChatCompletions, Responses

Constant Summary

Constants included from Support::Inspectable

Support::Inspectable::TRUNCATE_AT

Instance Attribute Summary

Attributes inherited from RubyLLM::Provider

#config, #connection

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RubyLLM::Provider

#animate_later, #assume_models_exist?, assume_models_exist?, #batch_cost, #batch_cost_amounts, #batch_cost_multiplier, #batch_protocol_name, #batch_results, #batch_status, #batches?, #cache_content, #cancel_batch, #capabilities, #compact, #complete, #configuration_requirements, #configured?, configured?, configured_providers, configured_remote_providers, #count_tokens, #create_batch, #delete_cache, display_name, #download_file, #embed, #extend_cache, #files?, #find_batch, #find_cache, #find_file, #find_research_job, #initialize, #list_file_uris, #list_models, local?, #local?, local_providers, #long_context_pricing?, model_registry_files, model_required?, models_dev_alias, models_dev_model_id, #moderate, #name, #ocr, #paint, #parse_error, #preprocess_message, protocol, #protocol_for, protocols, #protocols, providers, register, remote?, remote_providers, #render, #render_embedding, #rerank, #research_later, resolve, resolve!, resolve_registry_id, #retry_delay, #slug, #speak, #tokenize, #tool_approval_response, #transcribe, #upload_file

Methods included from Support::Inspectable

#full_inspect, #inspect, #pretty_print

Constructor Details

This class inherits a constructor from RubyLLM::Provider

Class Method Details

.capabilitiesObject



22
23
24
# File 'lib/ruby_llm/providers/xai.rb', line 22

def capabilities
  XAI::Capabilities
end

.configuration_optionsObject



26
27
28
# File 'lib/ruby_llm/providers/xai.rb', line 26

def configuration_options
  %i[xai_api_key xai_api_base]
end

.configuration_requirementsObject



30
31
32
# File 'lib/ruby_llm/providers/xai.rb', line 30

def configuration_requirements
  %i[xai_api_key]
end

Instance Method Details

#api_baseObject



11
12
13
# File 'lib/ruby_llm/providers/xai.rb', line 11

def api_base
  @config.xai_api_base || 'https://api.x.ai/v1'
end

#headersObject



15
16
17
18
19
# File 'lib/ruby_llm/providers/xai.rb', line 15

def headers
  {
    'Authorization' => "Bearer #{@config.xai_api_key}"
  }
end