Class: Anthropic::Resources::Models

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/models.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Models

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Models.



73
74
75
# File 'lib/anthropic/resources/models.rb', line 73

def initialize(client:)
  @client = client
end

Instance Method Details

#list(after_id: nil, before_id: nil, limit: nil, betas: nil, request_options: {}) ⇒ Anthropic::Internal::Page<Anthropic::Models::ModelInfo>

Some parameter documentations has been truncated, see Models::ModelListParams for more details.

List available models.

The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first.



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/anthropic/resources/models.rb', line 56

def list(params = {})
  parsed, options = Anthropic::ModelListParams.dump_request(params)
  query_params = [:after_id, :before_id, :limit]
  @client.request(
    method: :get,
    path: "v1/models",
    query: parsed.slice(*query_params),
    headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"),
    page: Anthropic::Internal::Page,
    model: Anthropic::ModelInfo,
    options: options
  )
end

#retrieve(model_id, betas: nil, request_options: {}) ⇒ Anthropic::Models::ModelInfo

Get a specific model.

The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID.



22
23
24
25
26
27
28
29
30
31
# File 'lib/anthropic/resources/models.rb', line 22

def retrieve(model_id, params = {})
  parsed, options = Anthropic::ModelRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v1/models/%1$s", model_id],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::ModelInfo,
    options: options
  )
end