Class: Aws::BedrockRuntime::Client
- Inherits:
-
Seahorse::Client::Base
- Object
- Seahorse::Client::Base
- Aws::BedrockRuntime::Client
- Includes:
- ClientStubs
- Defined in:
- lib/aws-sdk-bedrockruntime/client.rb
Overview
An API client for BedrockRuntime. To construct a client, you need to configure a ‘:region` and `:credentials`.
client = Aws::BedrockRuntime::Client.new(
region: region_name,
credentials: credentials,
# ...
)
For details on configuring region and credentials see the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).
See #initialize for a full list of supported configuration options.
Class Attribute Summary collapse
- .identifier ⇒ Object readonly private
API Operations collapse
-
#invoke_model(params = {}) ⇒ Types::InvokeModelResponse
Invokes the specified Bedrock model to run inference using the input provided in the request body.
-
#invoke_model_with_response_stream(params = {}) ⇒ Types::InvokeModelWithResponseStreamResponse
Invoke the specified Bedrock model to run inference using the input provided.
Class Method Summary collapse
- .errors_module ⇒ Object private
Instance Method Summary collapse
- #build_request(operation_name, params = {}) ⇒ Object private
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #waiter_names ⇒ Object deprecated private Deprecated.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
396 397 398 |
# File 'lib/aws-sdk-bedrockruntime/client.rb', line 396 def initialize(*args) super end |
Class Attribute Details
.identifier ⇒ Object (readonly)
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.
720 721 722 |
# File 'lib/aws-sdk-bedrockruntime/client.rb', line 720 def identifier @identifier end |
Class Method Details
.errors_module ⇒ Object
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.
723 724 725 |
# File 'lib/aws-sdk-bedrockruntime/client.rb', line 723 def errors_module Errors end |
Instance Method Details
#build_request(operation_name, params = {}) ⇒ Object
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.
698 699 700 701 702 703 704 705 706 707 708 709 |
# File 'lib/aws-sdk-bedrockruntime/client.rb', line 698 def build_request(operation_name, params = {}) handlers = @handlers.for(operation_name) context = Seahorse::Client::RequestContext.new( operation_name: operation_name, operation: config.api.operation(operation_name), client: self, params: params, config: config) context[:gem_name] = 'aws-sdk-bedrockruntime' context[:gem_version] = '1.1.0' Seahorse::Client::Request.new(handlers, context) end |
#invoke_model(params = {}) ⇒ Types::InvokeModelResponse
Invokes the specified Bedrock model to run inference using the input provided in the request body. You use InvokeModel to run inference for text models, image models, and embedding models.
For more information, see [Run inference] in the Bedrock User Guide.
For example requests, see Examples (after the Errors section).
[1]: docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html
458 459 460 461 |
# File 'lib/aws-sdk-bedrockruntime/client.rb', line 458 def invoke_model(params = {}, = {}) req = build_request(:invoke_model, params) req.send_request() end |
#invoke_model_with_response_stream(params = {}) ⇒ Types::InvokeModelWithResponseStreamResponse
Invoke the specified Bedrock model to run inference using the input provided. Return the response in a stream.
For more information, see [Run inference] in the Bedrock User Guide.
For an example request and response, see Examples (after the Errors section).
[1]: docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
# File 'lib/aws-sdk-bedrockruntime/client.rb', line 671 def invoke_model_with_response_stream(params = {}, = {}, &block) params = params.dup event_stream_handler = case handler = params.delete(:event_stream_handler) when EventStreams::ResponseStream then handler when Proc then EventStreams::ResponseStream.new.tap(&handler) when nil then EventStreams::ResponseStream.new else msg = "expected :event_stream_handler to be a block or "\ "instance of Aws::BedrockRuntime::EventStreams::ResponseStream"\ ", got `#{handler.inspect}` instead" raise ArgumentError, msg end yield(event_stream_handler) if block_given? req = build_request(:invoke_model_with_response_stream, params) req.context[:event_stream_handler] = event_stream_handler req.handlers.add(Aws::Binary::DecodeHandler, priority: 95) req.send_request(, &block) end |
#waiter_names ⇒ Object
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.
713 714 715 |
# File 'lib/aws-sdk-bedrockruntime/client.rb', line 713 def waiter_names [] end |