Class: SavvyOpenrouter::Resources::Models
- Defined in:
- lib/savvy_openrouter/resources/models.rb
Instance Method Summary collapse
- #count ⇒ Object
- #endpoints(author:, slug:) ⇒ Object
-
#first_ranked_free_text_model(category:, output_modalities: "text") ⇒ Object
Uses GET /models with filters, then returns the first model whose prompt + completion pricing are zero.
-
#list(**params) ⇒ Object
Query params match OpenRouter GET /models (e.g. category, output_modalities, supported_parameters).
- #user ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from SavvyOpenrouter::Resources::Base
Instance Method Details
#count ⇒ Object
25 26 27 28 29 |
# File 'lib/savvy_openrouter/resources/models.rb', line 25 def count conn.with_call_context(endpoint: "models_count", logical_model: nil) do conn.get("/models/count") end end |
#endpoints(author:, slug:) ⇒ Object
37 38 39 40 41 |
# File 'lib/savvy_openrouter/resources/models.rb', line 37 def endpoints(author:, slug:) conn.with_call_context(endpoint: "models_endpoints", logical_model: nil) do conn.get("/models/#{}/#{slug}/endpoints") end end |
#first_ranked_free_text_model(category:, output_modalities: "text") ⇒ Object
Uses GET /models with filters, then returns the first model whose prompt + completion pricing are zero. OpenRouter returns models in curated rank order within a category; first matching free model aligns with site “top free” picks when combined with output_modalities=text.
19 20 21 22 23 |
# File 'lib/savvy_openrouter/resources/models.rb', line 19 def first_ranked_free_text_model(category:, output_modalities: "text") res = list(category: category, output_modalities: output_modalities) data = res[:data] || [] data.find { |m| free_pricing?(m) } end |
#list(**params) ⇒ Object
Query params match OpenRouter GET /models (e.g. category, output_modalities, supported_parameters).
9 10 11 12 13 14 |
# File 'lib/savvy_openrouter/resources/models.rb', line 9 def list(**params) query = stringify_query(params) conn.with_call_context(endpoint: "models", logical_model: nil) do conn.get("/models", params: query.empty? ? nil : query) end end |
#user ⇒ Object
31 32 33 34 35 |
# File 'lib/savvy_openrouter/resources/models.rb', line 31 def user conn.with_call_context(endpoint: "models_user", logical_model: nil) do conn.get("/models/user") end end |