AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Container for the parameters to the ConverseStream operation.
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.
To find out if a model supports streaming, call GetFoundationModel
and check the responseStreamingSupported
field in the response.
The CLI doesn't support streaming operations in Amazon Bedrock, including ConverseStream
.
Amazon Bedrock doesn't store any text, images, or documents that you provide as content. The data is only used to generate the response.
You can submit a prompt by including it in the messages
field, specifying the
modelId
of a foundation model or inference profile to run inference on it,
and including any other fields that are relevant to your use case.
You can also submit a prompt from Prompt management by specifying the ARN of the prompt
version and including a map of variables to values in the promptVariables
field.
You can append more messages to the prompt by using the messages
field. If
you use a prompt from Prompt management, you can't include the following fields in
the request: additionalModelRequestFields
, inferenceConfig
, system
,
or toolConfig
. Instead, these fields must be defined through Prompt management.
For more information, see Use
a prompt from Prompt management.
For information about the Converse API, see Use the Converse API in the Amazon Bedrock User Guide. To use a guardrail, see Use a guardrail with the Converse API in the Amazon Bedrock User Guide. To use a tool with a model, see Tool use (Function calling) in the Amazon Bedrock User Guide
For example code, see Conversation streaming example in the Amazon Bedrock User Guide.
This operation requires permission for the bedrock:InvokeModelWithResponseStream
action.
To deny all inference access to resources that you specify in the modelId field, you
need to deny access to the bedrock:InvokeModel
and bedrock:InvokeModelWithResponseStream
actions. Doing this also denies access to the resource through the base inference
actions (InvokeModel
and InvokeModelWithResponseStream).
For more information see Deny
access for inference on specific models.
For troubleshooting some of the common errors you might encounter when using the ConverseStream
API, see Troubleshooting
Amazon Bedrock API Error Codes in the Amazon Bedrock User Guide
Namespace: Amazon.BedrockRuntime.Model
Assembly: AWSSDK.BedrockRuntime.dll
Version: 3.x.y.z
public class ConverseStreamRequest : AmazonBedrockRuntimeRequest IAmazonWebServiceRequest
The ConverseStreamRequest type exposes the following members
Name | Description | |
---|---|---|
![]() |
ConverseStreamRequest() |
Name | Type | Description | |
---|---|---|---|
![]() |
AdditionalModelRequestFields | Amazon.Runtime.Documents.Document |
Gets and sets the property AdditionalModelRequestFields.
Additional inference parameters that the model supports, beyond the base set of inference
parameters that |
![]() |
AdditionalModelResponseFieldPaths | System.Collections.Generic.List<System.String> |
Gets and sets the property AdditionalModelResponseFieldPaths.
Additional model parameters field paths to return in the response.
For information about the JSON Pointer syntax, see the Internet Engineering Task Force (IETF) documentation.
|
![]() |
GuardrailConfig | Amazon.BedrockRuntime.Model.GuardrailStreamConfiguration |
Gets and sets the property GuardrailConfig.
Configuration information for a guardrail that you want to use in the request. If
you include |
![]() |
InferenceConfig | Amazon.BedrockRuntime.Model.InferenceConfiguration |
Gets and sets the property InferenceConfig.
Inference parameters to pass to the model. |
![]() |
Messages | System.Collections.Generic.List<Amazon.BedrockRuntime.Model.Message> |
Gets and sets the property Messages. The messages that you want to send to the model. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true. |
![]() |
ModelId | System.String |
Gets and sets the property ModelId. Specifies the model or throughput with which to run inference, or the prompt resource to use in inference. The value depends on the resource that you use:
The Converse API doesn't support imported models. |
![]() |
PerformanceConfig | Amazon.BedrockRuntime.Model.PerformanceConfiguration |
Gets and sets the property PerformanceConfig. Model performance settings for the request. |
![]() |
PromptVariables | System.Collections.Generic.Dictionary<System.String, Amazon.BedrockRuntime.Model.PromptVariableValues> |
Gets and sets the property PromptVariables.
Contains a map of variables in a prompt from Prompt management to objects containing
the values to fill in for them when running model invocation. This field is ignored
if you don't specify a prompt resource in the |
![]() |
RequestMetadata | System.Collections.Generic.Dictionary<System.String, System.String> |
Gets and sets the property RequestMetadata. Key-value pairs that you can use to filter invocation logs. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true. |
![]() |
System | System.Collections.Generic.List<Amazon.BedrockRuntime.Model.SystemContentBlock> |
Gets and sets the property System. A prompt that provides instructions or context to the model about the task it should perform, or the persona it should adopt during the conversation. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true. |
![]() |
ToolConfig | Amazon.BedrockRuntime.Model.ToolConfiguration |
Gets and sets the property ToolConfig. Configuration information for the tools that the model can use when generating a response. For information about models that support streaming tool use, see Supported models and model features. |
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.7.2 and newer