Skip to content

Commit 5ba6814

Browse files
authored
Add back non-streaming docs (#78)
1 parent 52a653a commit 5ba6814

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

docs/user-guide/concepts/model-providers/amazon-bedrock.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,30 @@ The [`BedrockModel`](../../../api-reference/models.md#strands.models.bedrock) cl
1616

1717
1. **AWS Account**: You need an AWS account with access to Amazon Bedrock
1818
2. **Model Access**: Request access to your desired models in the Amazon Bedrock console
19-
3. **AWS Credentials**: Configure AWS credentials with appropriate permissions, including `bedrock:InvokeModelWithResponseStream`
19+
3. **AWS Credentials**: Configure AWS credentials with appropriate permissions
2020

2121
#### Required IAM Permissions
2222

2323
To use Amazon Bedrock with Strands, your IAM user or role needs the following permissions:
2424

25-
- `bedrock:InvokeModelWithResponseStream`
25+
- `bedrock-runtime:InvokeModelWithResponseStream` (for streaming mode)
26+
- `bedrock-runtime:InvokeModel` (for non-streaming mode)
2627

2728
Here's a sample IAM policy that grants the necessary permissions:
2829

2930
```json
3031
{
31-
"Version": "2012-10-17",
32-
"Statement": [
33-
{
34-
"Effect": "Allow",
35-
"Action": ["bedrock:InvokeModelWithResponseStream"],
36-
"Resource": "*"
37-
}
38-
]
32+
"Version": "2012-10-17",
33+
"Statement": [
34+
{
35+
"Effect": "Allow",
36+
"Action": [
37+
"bedrock-runtime:InvokeModelWithResponseStream",
38+
"bedrock-runtime:InvokeModel"
39+
],
40+
"Resource": "*"
41+
}
42+
]
3943
}
4044
```
4145

@@ -57,7 +61,7 @@ The model access request is typically processed immediately. Once approved, the
5761

5862
For more details, see the [Amazon Bedrock documentation on modifying model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access-modify.html).
5963

60-
#### Setting Up AWS Credentials & Region
64+
#### Setting Up AWS Credentials
6165

6266
Strands uses [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) (the AWS SDK for Python) to make calls to Amazon Bedrock. Boto3 has its own credential resolution system that determines which credentials to use when making requests to AWS.
6367

@@ -156,6 +160,7 @@ The [`BedrockModel`](../../../api-reference/models.md#strands.models.bedrock) su
156160
| [`boto_session`](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html) | Boto Session to use when creating the Boto3 Bedrock Client | Boto Session with region: "us-west-2" |
157161
| [`boto_client_config`](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html) | Botocore Configuration used when creating the Boto3 Bedrock Client | - |
158162
| [`region_name`](https://docs.aws.amazon.com/general/latest/gr/bedrock.html) | AWS region to use for the Bedrock service | "us-west-2" |
163+
| [`streaming`](https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods.html) | Flag to enable/disable streaming mode | True |
159164
| [`temperature`](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InferenceConfiguration.html#API_runtime_InferenceConfiguration_Contents) | Controls randomness (higher = more random) | [Model-specific default](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html) |
160165
| [`max_tokens`](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InferenceConfiguration.html#API_runtime_InferenceConfiguration_Contents) | Maximum number of tokens to generate | [Model-specific default](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html) |
161166
| [`top_p`](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InferenceConfiguration.html#API_runtime_InferenceConfiguration_Contents) | Controls diversity via nucleus sampling | [Model-specific default](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html) |
@@ -207,6 +212,27 @@ response = agent("Write a short story about an AI assistant.")
207212

208213
## Advanced Features
209214

215+
### Streaming vs Non-Streaming Mode
216+
217+
Certain Amazon Bedrock models only support non-streaming tool use, so you can set the `streaming` configuration to false
218+
in order to use these models. Both modes provide the same event structure and functionality in your agent, as the non-streaming responses are converted to the streaming format internally.
219+
220+
```python
221+
# Streaming model (default)
222+
streaming_model = BedrockModel(
223+
model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
224+
streaming=True, # This is the default
225+
)
226+
227+
# Non-streaming model
228+
non_streaming_model = BedrockModel(
229+
model_id="us.meta.llama3-2-90b-instruct-v1:0",
230+
streaming=False, # Disable streaming
231+
)
232+
```
233+
234+
See the Amazon Bedrock documentation for [Supported models and model features](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html) to learn about the streaming support for different models.
235+
210236
### Multimodal Support
211237

212238
Some Bedrock models support multimodal inputs (Documents, Images, etc.). Here's how to use them:

0 commit comments

Comments
 (0)