Class: OpenRouter::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/open_router.rb

Constant Summary collapse

DEFAULT_API_VERSION =
"v1"
DEFAULT_REQUEST_TIMEOUT =
120
DEFAULT_URI_BASE =
"https://openrouter.ai/api"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
# File 'lib/open_router.rb', line 22

def initialize
  self.access_token = nil
  self.api_version = DEFAULT_API_VERSION
  self.extra_headers = {}
  self.log_errors = false
  self.request_timeout = DEFAULT_REQUEST_TIMEOUT
  self.uri_base = DEFAULT_URI_BASE
end

Instance Attribute Details

#access_tokenObject

Raises:



31
32
33
34
35
# File 'lib/open_router.rb', line 31

def access_token
  return @access_token if @access_token

  raise ConfigurationError, "OpenRouter access token missing!"
end

#api_versionObject

Returns the value of attribute api_version.



16
17
18
# File 'lib/open_router.rb', line 16

def api_version
  @api_version
end

#extra_headersObject

Returns the value of attribute extra_headers.



16
17
18
# File 'lib/open_router.rb', line 16

def extra_headers
  @extra_headers
end

#faraday_configObject

Returns the value of attribute faraday_config.



16
17
18
# File 'lib/open_router.rb', line 16

def faraday_config
  @faraday_config
end

#log_errorsObject

Returns the value of attribute log_errors.



16
17
18
# File 'lib/open_router.rb', line 16

def log_errors
  @log_errors
end

#request_timeoutObject

Returns the value of attribute request_timeout.



16
17
18
# File 'lib/open_router.rb', line 16

def request_timeout
  @request_timeout
end

#uri_baseObject

Returns the value of attribute uri_base.



16
17
18
# File 'lib/open_router.rb', line 16

def uri_base
  @uri_base
end

Instance Method Details

#faraday(&block) ⇒ Object



37
38
39
# File 'lib/open_router.rb', line 37

def faraday(&block)
  self.faraday_config = block
end

#site_name=(value) ⇒ Object



41
42
43
# File 'lib/open_router.rb', line 41

def site_name=(value)
  @extra_headers["X-Title"] = value
end

#site_url=(value) ⇒ Object



45
46
47
# File 'lib/open_router.rb', line 45

def site_url=(value)
  @extra_headers["HTTP-Referer"] = value
end