Class: LLM::Bedrock::Models

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/providers/bedrock/models.rb

Overview

The Models class provides a model object for interacting with [AWS Bedrock’s ListFoundationModels API]( docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html).

Unlike the Converse API (which lives on ‘bedrock-runtime.<region>.amazonaws.com`), the models endpoint lives on the control plane at `bedrock.<region>.amazonaws.com`. This class builds a matching transport for the control-plane host from the provider’s current transport class.

Examples:

llm = LLM.bedrock(
  access_key_id: ENV["AWS_ACCESS_KEY_ID"],
  secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
  region: "us-east-1"
)
llm.models.all.each { |m| puts m.id }

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ LLM::Bedrock::Models

Parameters:



26
27
28
# File 'lib/llm/providers/bedrock/models.rb', line 26

def initialize(provider)
  @provider = provider
end

Instance Method Details

#all(**params) ⇒ LLM::Response

Note:

This calls AWS Bedrock’s ListFoundationModels API which returns all models available in the region, not just the ones the current account is subscribed to.

List all foundation models available in the configured region.

Parameters:

  • params (Hash)

    Optional query parameters (e.g. ‘byProvider: “Anthropic”`, `byInferenceType: “ON_DEMAND”`)

Returns:



41
42
43
44
45
46
# File 'lib/llm/providers/bedrock/models.rb', line 41

def all(**params)
  host = credentials.host
  req = build_request(host, params)
  res = build_transport(host).request(req, owner: self)
  handle_response(res)
end