BedrockRuntime class

Describes the API operations for running inference using Amazon Bedrock models.

Constructors

BedrockRuntime({required String region, AwsClientCredentials? credentials, AwsClientCredentialsProvider? credentialsProvider, Client? client, String? endpointUrl})

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

applyGuardrail({required List<GuardrailContentBlock> content, required String guardrailIdentifier, required String guardrailVersion, required GuardrailContentSource source, GuardrailOutputScope? outputScope}) Future<ApplyGuardrailResponse>
The action to apply a guardrail.
close() → void
Closes the internal HTTP client if none was provided at creation. If a client was passed as a constructor argument, this becomes a noop.
converse({required String modelId, Document? additionalModelRequestFields, List<String>? additionalModelResponseFieldPaths, GuardrailConfiguration? guardrailConfig, InferenceConfiguration? inferenceConfig, List<Message>? messages, OutputConfig? outputConfig, PerformanceConfiguration? performanceConfig, Map<String, PromptVariableValues>? promptVariables, Map<String, String>? requestMetadata, ServiceTier? serviceTier, List<SystemContentBlock>? system, ToolConfiguration? toolConfig}) Future<ConverseResponse>
Sends messages to the specified Amazon Bedrock model. Converse provides a consistent interface that works with all models that support messages. This allows you to write code once and use it with different models. If a model has unique inference parameters, you can also pass those unique parameters to the model.
converseStream({required String modelId, Document? additionalModelRequestFields, List<String>? additionalModelResponseFieldPaths, GuardrailStreamConfiguration? guardrailConfig, InferenceConfiguration? inferenceConfig, List<Message>? messages, OutputConfig? outputConfig, PerformanceConfiguration? performanceConfig, Map<String, PromptVariableValues>? promptVariables, Map<String, String>? requestMetadata, ServiceTier? serviceTier, List<SystemContentBlock>? system, ToolConfiguration? toolConfig}) Future<ConverseStreamResponse>
Sends messages to the specified Amazon Bedrock model and returns the response in a stream. ConverseStream provides a consistent API that works with all Amazon Bedrock models that support messages. This allows you to write code once and use it with different models. Should a model have unique inference parameters, you can also pass those unique parameters to the model.
countTokens({required CountTokensInput input, required String modelId}) Future<CountTokensResponse>
Returns the token count for a given inference request. This operation helps you estimate token usage before sending requests to foundation models by returning the token count that would be used if the same input were sent to the model in an inference request.
getAsyncInvoke({required String invocationArn}) Future<GetAsyncInvokeResponse>
Retrieve information about an asynchronous invocation.
invokeModel({required String modelId, String? accept, Uint8List? body, String? contentType, String? guardrailIdentifier, String? guardrailVersion, PerformanceConfigLatency? performanceConfigLatency, String? requestMetadata, ServiceTierType? serviceTier, Trace? trace}) Future<InvokeModelResponse>
Invokes the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. You use model inference to generate text, images, and embeddings.
invokeModelWithBidirectionalStream({required InvokeModelWithBidirectionalStreamInput body, required String modelId}) Future<InvokeModelWithBidirectionalStreamResponse>
Invoke the specified Amazon Bedrock model to run inference using the bidirectional stream. The response is returned in a stream that remains open for 8 minutes. A single session can contain multiple prompts and responses from the model. The prompts to the model are provided as audio files and the model's responses are spoken back to the user and transcribed.
invokeModelWithResponseStream({required String modelId, String? accept, Uint8List? body, String? contentType, String? guardrailIdentifier, String? guardrailVersion, PerformanceConfigLatency? performanceConfigLatency, String? requestMetadata, ServiceTierType? serviceTier, Trace? trace}) Future<InvokeModelWithResponseStreamResponse>
Invoke the specified Amazon Bedrock model to run inference using the prompt and inference parameters provided in the request body. The response is returned in a stream.
listAsyncInvokes({int? maxResults, String? nextToken, SortAsyncInvocationBy? sortBy, SortOrder? sortOrder, AsyncInvokeStatus? statusEquals, DateTime? submitTimeAfter, DateTime? submitTimeBefore}) Future<ListAsyncInvokesResponse>
Lists asynchronous invocations.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startAsyncInvoke({required String modelId, required Object modelInput, required AsyncInvokeOutputDataConfig outputDataConfig, String? clientRequestToken, List<Tag>? tags}) Future<StartAsyncInvokeResponse>
Starts an asynchronous invocation.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited