Module: RubyLLM::Protocols::Anthropic::Models

Defined in:
lib/ruby_llm/protocols/anthropic/models.rb

Overview

Models methods of the Anthropic API integration

Constant Summary collapse

ITERATION_TOKEN_KEYS =
%w[
  input_tokens output_tokens cache_read_input_tokens cache_creation_input_tokens
].freeze
REPORTED_CAPABILITIES =
{
  'batch' => 'batch',
  'citations' => 'citations',
  'image_input' => 'vision',
  'structured_outputs' => 'structured_output',
  'thinking' => 'reasoning'
}.freeze

Instance Method Summary collapse

Instance Method Details

#list_modelsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby_llm/protocols/anthropic/models.rb', line 22

def list_models
  models = []
  after_id = nil

  loop do
    response = @connection.get(models_url) do |req|
      req.params = { limit: 1000 }
      req.params[:after_id] = after_id if after_id
    end

    models.concat(parse_list_models_response(response, @provider.slug))
    break unless response.body['has_more']

    after_id = response.body['last_id']
  end

  models
end