Class: Anthropic::Resources::Models

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

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.

Parameters:

API:

  • private



84
85
86
# File 'lib/anthropic/resources/models.rb', line 84

def initialize(client:)
  @client = client
end

Instance Method Details

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

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.

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

Parameters:

  • Query param: ID of the object to use as a cursor for pagination. When provided,

  • Query param: ID of the object to use as a cursor for pagination. When provided,

  • Query param: Number of items to return per page.

  • Header param: Optional header to specify the beta version(s) you want to use.

  • Header param: Optional header to select the Workspace for this request. The valu

Returns:

See Also:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/anthropic/resources/models.rb', line 63

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

#retrieve(model_id, betas: nil, workspace_id: 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.

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

Parameters:

  • Model identifier or alias.

  • Optional header to specify the beta version(s) you want to use.

  • Optional header to select the Workspace for this request. The value is a Workspa

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
# File 'lib/anthropic/resources/models.rb', line 27

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", workspace_id: "anthropic-workspace-id"),
    model: Anthropic::ModelInfo,
    options: options
  )
end