Class: OpenRouter::Configuration
- Inherits:
-
Object
- Object
- OpenRouter::Configuration
- 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
- #access_token ⇒ Object
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#extra_headers ⇒ Object
Returns the value of attribute extra_headers.
-
#faraday_config ⇒ Object
Returns the value of attribute faraday_config.
-
#log_errors ⇒ Object
Returns the value of attribute log_errors.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
-
#uri_base ⇒ Object
Returns the value of attribute uri_base.
Instance Method Summary collapse
- #faraday(&block) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #site_name=(value) ⇒ Object
- #site_url=(value) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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_token ⇒ Object
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_version ⇒ Object
Returns the value of attribute api_version.
16 17 18 |
# File 'lib/open_router.rb', line 16 def api_version @api_version end |
#extra_headers ⇒ Object
Returns the value of attribute extra_headers.
16 17 18 |
# File 'lib/open_router.rb', line 16 def extra_headers @extra_headers end |
#faraday_config ⇒ Object
Returns the value of attribute faraday_config.
16 17 18 |
# File 'lib/open_router.rb', line 16 def faraday_config @faraday_config end |
#log_errors ⇒ Object
Returns the value of attribute log_errors.
16 17 18 |
# File 'lib/open_router.rb', line 16 def log_errors @log_errors end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
16 17 18 |
# File 'lib/open_router.rb', line 16 def request_timeout @request_timeout end |
#uri_base ⇒ Object
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 |