Class: Riffer::Providers::OpenRouter
- Defined in:
- lib/riffer/providers/open_router.rb
Overview
OpenRouter provider for the OpenRouter unified gateway (openrouter.ai).
Requires the openai gem to be installed. OpenRouter exposes an OpenAI-compatible Chat Completions endpoint, so this provider reuses the OpenAI Ruby SDK with a base_url override.
The api_key falls back to Riffer.config.openrouter.api_key and then to OPENROUTER_API_KEY.
Constant Summary collapse
- BASE_URL =
: String
"https://openrouter.ai/api/v1"
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(api_key: nil, **options) ⇒ OpenRouter
constructor
Initializes the OpenRouter provider.
Methods inherited from Base
#generate_text, skills_adapter, #stream_text
Methods included from Messages::Converter
#convert_to_file_part, #convert_to_message_object
Methods included from Helpers::Dependencies
Constructor Details
#initialize(api_key: nil, **options) ⇒ OpenRouter
Initializes the OpenRouter provider.
– : (?api_key: String?, **untyped) -> void
21 22 23 24 25 26 27 |
# File 'lib/riffer/providers/open_router.rb', line 21 def initialize(api_key: nil, **) depends_on "openai" api_key ||= Riffer.config.openrouter.api_key || ENV["OPENROUTER_API_KEY"] @client = ::OpenAI::Client.new(api_key: api_key, base_url: BASE_URL, **) end |