File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ RubyLLM.configure do |config|
54
54
config.openrouter_api_key = ENV .fetch(' OPENROUTER_API_KEY' , nil )
55
55
config.ollama_api_base = ENV .fetch(' OLLAMA_API_BASE' , nil )
56
56
57
+ # --- Open Router Configuration ---
58
+ config.openrouter_referer = ' https://rubyllm.com'
59
+ config.openrouter_title = ' RubyLLM'
60
+
57
61
# --- AWS Bedrock Credentials ---
58
62
# Uses standard AWS credential chain (environment, shared config, IAM role)
59
63
# if these specific keys aren't set. Region is required if using Bedrock.
@@ -224,4 +228,3 @@ default_response = default_chat.ask("Query using global production settings...")
224
228
* ** Thread Safety:** Each context is independent, making them safe for use across different threads.
225
229
226
230
Contexts provide a clean and safe mechanism for managing diverse configuration needs within a single application.
227
-
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ class Configuration
23
23
:bedrock_region ,
24
24
:bedrock_session_token ,
25
25
:openrouter_api_key ,
26
+ :openrouter_referer ,
27
+ :openrouter_title ,
26
28
:ollama_api_base ,
27
29
# Default models
28
30
:default_model ,
Original file line number Diff line number Diff line change @@ -14,10 +14,13 @@ def api_base(_config)
14
14
'https://openrouter.ai/api/v1'
15
15
end
16
16
17
+ # @see https://openrouter.ai/docs/api-reference/overview#headers
17
18
def headers ( config )
18
19
{
19
- 'Authorization' => "Bearer #{ config . openrouter_api_key } "
20
- }
20
+ 'Authorization' => "Bearer #{ config . openrouter_api_key } " ,
21
+ 'HTTP-Referer' => config . openrouter_referer , # Optional: Site URL for rankings on openrouter.ai.
22
+ 'X-Title' => config . openrouter_title # Optional: Site title for rankings on openrouter.ai.
23
+ } . compact
21
24
end
22
25
23
26
def slug
You can’t perform that action at this time.
0 commit comments