Class: SavvyOpenrouter::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/savvy_openrouter/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path: nil, **options) ⇒ Client

Returns a new instance of Client.



38
39
40
41
# File 'lib/savvy_openrouter/client.rb', line 38

def initialize(config_path: nil, **options)
  @config = Configuration.new(config_path: config_path, **options)
  @connection = Connection.new(@config)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



26
27
28
# File 'lib/savvy_openrouter/client.rb', line 26

def config
  @config
end

#connectionObject (readonly)

Returns the value of attribute connection.



26
27
28
# File 'lib/savvy_openrouter/client.rb', line 26

def connection
  @connection
end

Instance Method Details

#analyticsObject



83
84
85
# File 'lib/savvy_openrouter/client.rb', line 83

def analytics
  @analytics ||= Resources::Analytics.new(self)
end

#anthropic_messagesObject



51
52
53
# File 'lib/savvy_openrouter/client.rb', line 51

def anthropic_messages
  @anthropic_messages ||= Resources::AnthropicMessages.new(self)
end

#api_call_loggerObject

Optional DB-backed request logging; see README (api_call_log).



29
30
31
# File 'lib/savvy_openrouter/client.rb', line 29

def api_call_logger
  connection.api_call_logger
end

#api_keysObject



99
100
101
# File 'lib/savvy_openrouter/client.rb', line 99

def api_keys
  @api_keys ||= Resources::ApiKeys.new(self)
end

#audioObject



87
88
89
# File 'lib/savvy_openrouter/client.rb', line 87

def audio
  @audio ||= Resources::Audio.new(self)
end

#chatObject



43
44
45
# File 'lib/savvy_openrouter/client.rb', line 43

def chat
  @chat ||= Resources::Chat.new(self)
end

#creditsObject



67
68
69
# File 'lib/savvy_openrouter/client.rb', line 67

def credits
  @credits ||= Resources::Credits.new(self)
end

#embeddingsObject



55
56
57
# File 'lib/savvy_openrouter/client.rb', line 55

def embeddings
  @embeddings ||= Resources::Embeddings.new(self)
end

#endpointsObject



79
80
81
# File 'lib/savvy_openrouter/client.rb', line 79

def endpoints
  @endpoints ||= Resources::Endpoints.new(self)
end

#generationsObject



75
76
77
# File 'lib/savvy_openrouter/client.rb', line 75

def generations
  @generations ||= Resources::Generations.new(self)
end

#guardrailsObject



107
108
109
# File 'lib/savvy_openrouter/client.rb', line 107

def guardrails
  @guardrails ||= Resources::Guardrails.new(self)
end

#modelsObject



63
64
65
# File 'lib/savvy_openrouter/client.rb', line 63

def models
  @models ||= Resources::Models.new(self)
end

#oauthObject



95
96
97
# File 'lib/savvy_openrouter/client.rb', line 95

def oauth
  @oauth ||= Resources::OAuth.new(self)
end

#organizationObject



103
104
105
# File 'lib/savvy_openrouter/client.rb', line 103

def organization
  @organization ||= Resources::Organization.new(self)
end

#providersObject



71
72
73
# File 'lib/savvy_openrouter/client.rb', line 71

def providers
  @providers ||= Resources::Providers.new(self)
end

#record_api_call(attrs) ⇒ Object

Merge active with_call_context stack attrs and persist one row (e.g. structured-output failure after HTTP 200).



34
35
36
# File 'lib/savvy_openrouter/client.rb', line 34

def record_api_call(attrs)
  connection.record_manual_api_call(attrs)
end

#rerankObject



59
60
61
# File 'lib/savvy_openrouter/client.rb', line 59

def rerank
  @rerank ||= Resources::Rerank.new(self)
end

#responsesObject



47
48
49
# File 'lib/savvy_openrouter/client.rb', line 47

def responses
  @responses ||= Resources::Responses.new(self)
end

#videosObject



91
92
93
# File 'lib/savvy_openrouter/client.rb', line 91

def videos
  @videos ||= Resources::Videos.new(self)
end

#workspacesObject



111
112
113
# File 'lib/savvy_openrouter/client.rb', line 111

def workspaces
  @workspaces ||= Resources::Workspaces.new(self)
end