Module: RailsAgents::Providers

Defined in:
lib/rails_agents/providers/base.rb,
lib/rails_agents/providers/grok.rb,
lib/rails_agents/providers/openai.rb,
lib/rails_agents/providers/anthropic.rb,
lib/rails_agents/providers/open_router.rb,
lib/rails_agents/providers/anthropic/files.rb,
lib/rails_agents/providers/openai_compatible.rb

Defined Under Namespace

Classes: Anthropic, Base, Grok, OpenAI, OpenAICompatible, OpenRouter

Class Method Summary collapse

Class Method Details

.build(name, api_key: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rails_agents/providers/base.rb', line 11

def self.build(name, api_key: nil)
  kwargs = api_key.nil? ? {} : {api_key: api_key}

  case name.to_sym
  when :openai then OpenAI.new(**kwargs)
  when :anthropic then Anthropic.new(**kwargs)
  when :openrouter then OpenRouter.new(**kwargs)
  when :grok then Grok.new(**kwargs)
  else raise ConfigurationError, "Unknown provider: #{name}. Use: #{Configuration::PROVIDERS.join(', ')}"
  end
end