Class: Riffer::Providers::OpenRouter

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

Overview

OpenRouter provider (openrouter.ai). Requires the openai gem —OpenRouter exposes an OpenAI-compatible endpoint, so this reuses the OpenAI SDK with a base_url override. api_key falls back to config, then OPENROUTER_API_KEY.

Constant Summary collapse

BASE_URL =

: String

"https://openrouter.ai/api/v1"

Constants inherited from Base

Base::WIRE_SEPARATOR

Instance Method Summary collapse

Methods inherited from Base

#generate_text, skills_adapter, #stream_text

Constructor Details

#initialize(api_key: nil, **options) ⇒ OpenRouter

– : (?api_key: String?, **untyped) -> void



15
16
17
18
19
20
21
# File 'lib/riffer/providers/open_router.rb', line 15

def initialize(api_key: nil, **options)
  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, **options)
end