Class: Anthropic::Resources::Beta::Models

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/models.rb,
sig/anthropic/resources/beta/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:



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

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::Beta::BetaModelInfo>

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::Beta::ModelListParams for more details.

Parameters:

  • after_id (String)

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

  • before_id (String)

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

  • limit (Integer)

    Query param: Number of items to return per page.

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>)

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

  • workspace_id (String)

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

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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

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

#retrieve(model_id, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::BetaModelInfo

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::Beta::ModelRetrieveParams for more details.

Parameters:

  • model_id (String)

    Model identifier or alias.

  • betas (Array<String, Symbol, Anthropic::Models::AnthropicBeta>)

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

  • workspace_id (String)

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

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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

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