Class: ActiveAgent::Providers::OpenRouter::Options
- Inherits:
-
ActiveAgent::Providers::OpenAI::Options
- Object
- Common::BaseModel
- ActiveAgent::Providers::OpenAI::Options
- ActiveAgent::Providers::OpenRouter::Options
- Defined in:
- lib/active_agent/providers/open_router/options.rb
Overview
Configuration options for OpenRouter provider
Extends OpenAI::Options with OpenRouter-specific settings including HTTP-Referer and X-Title headers for app identification and ranking.
Instance Attribute Summary collapse
-
#app_name ⇒ String
Application name for X-Title header (default: “ActiveAgent” or Rails app name).
-
#base_url ⇒ String
API endpoint (default: “openrouter.ai/api/v1”).
-
#site_url ⇒ String
Site URL for HTTP-Referer header (default: “activeagents.ai/” or Rails URL).
Instance Method Summary collapse
-
#extra_headers ⇒ Hash
Returns extra headers for OpenRouter API.
-
#initialize(kwargs = {}) ⇒ Options
constructor
Creates new OpenRouter options with auto-resolution.
-
#serialize ⇒ Hash
Serializes options for API requests.
Methods inherited from Common::BaseModel
#<=>, #==, attribute, #deep_compact, #deep_dup, delegate_attributes, drop_attributes, inherited, #inspect, keys, #merge!, required_attributes, #to_h, #to_hash
Constructor Details
#initialize(kwargs = {}) ⇒ Options
Creates new OpenRouter options with auto-resolution
Automatically resolves app_name from Rails application name and site_url from Rails routes/ActionMailer default_url_options.
53 54 55 56 57 58 59 60 |
# File 'lib/active_agent/providers/open_router/options.rb', line 53 def initialize(kwargs = {}) kwargs = kwargs.deep_symbolize_keys if kwargs.respond_to?(:deep_symbolize_keys) super(**deep_compact(kwargs.merge( app_name: kwargs[:app_name] || resolve_app_name(kwargs), site_url: kwargs[:site_url] || resolve_site_url(kwargs), ))) end |
Instance Attribute Details
#app_name ⇒ String
Returns application name for X-Title header (default: “ActiveAgent” or Rails app name).
37 |
# File 'lib/active_agent/providers/open_router/options.rb', line 37 attribute :app_name, :string, fallback: "ActiveAgent" |
#base_url ⇒ String
Returns API endpoint (default: “openrouter.ai/api/v1”).
33 |
# File 'lib/active_agent/providers/open_router/options.rb', line 33 attribute :base_url, :string, as: "https://openrouter.ai/api/v1" |
#site_url ⇒ String
Returns site URL for HTTP-Referer header (default: “activeagents.ai/” or Rails URL).
41 |
# File 'lib/active_agent/providers/open_router/options.rb', line 41 attribute :site_url, :string, fallback: "https://activeagents.ai/" |
Instance Method Details
#extra_headers ⇒ Hash
Returns extra headers for OpenRouter API
Maps app_name and site_url to OpenRouter’s required headers:
-
HTTP-Referer: site_url
-
X-Title: app_name
78 79 80 81 82 83 |
# File 'lib/active_agent/providers/open_router/options.rb', line 78 def extra_headers deep_compact( "http-referer" => site_url.presence, "x-title" => app_name.presence ) end |
#serialize ⇒ Hash
Serializes options for API requests
Excludes app_name and site_url as they’re sent via headers.
67 68 69 |
# File 'lib/active_agent/providers/open_router/options.rb', line 67 def serialize super.except(:app_name, :site_url) end |