class RubyLLM::Providers::OpenRouter
OpenRouter API integration.
Public Class Methods
Source
# File lib/ruby_llm/providers/openrouter.rb, line 52 def configuration_options %i[openrouter_api_key openrouter_api_base] end
# File lib/ruby_llm/providers/openrouter.rb, line 56 def configuration_requirements %i[openrouter_api_key] end
Public Instance Methods
Source
# File lib/ruby_llm/providers/openrouter.rb, line 12 def api_base @config.openrouter_api_base || 'https://openrouter.ai/api/v1' end
Source
# File lib/ruby_llm/providers/openrouter.rb, line 16 def headers { 'Authorization' => "Bearer #{@config.openrouter_api_key}" } end
Source
# File lib/ruby_llm/providers/openrouter.rb, line 22 def parse_error(response) return if response.body.empty? body = try_parse_json(response.body) case body when Hash parse_error_part_message body when Array body.map do |part| parse_error_part_message part end.join('. ') else body end end