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 manages its own HTTP connection since the provider’s transport is pinned to the runtime host.

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:



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

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:



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

def all(**params)
  host = credentials.host
  handle_response http(host).request(build_request(host, params))
end