Create a flow in Amazon Bedrock
To create a flow, you minimally provide a name and description for the flow and specify a service role with the proper permissions (or let the Amazon Bedrock console automatically create one for you). You will then define the flow by configuring nodes, which act as steps in the flow, and connections between the nodes. Before creating a flow, we recommend that you read How Amazon Bedrock Flows works to familiarize yourself with concepts and terms in Amazon Bedrock Flows and to learn about the types of nodes that are available to you. To learn how to create a flow select the tab corresponding to your method of choice and follow the steps:
- Console
-
To create a flow
-
Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at
Getting Started with the AWS Management Console.
-
Select Amazon Bedrock Flows from the left navigation pane.
-
In the Amazon Bedrock Flows section, choose Create flow.
-
Enter a Name for the flow and an optional Description.
-
For the Service role name, choose one of the following options:
-
(Optional) To encrypt your flow with a KMS key, select Customize encryption settings (advanced) and choose the key. For more information, see Key policy to allow Amazon Bedrock to encrypt and decrypt a flow.
-
Choose Create. Your flow is created and you will be taken to the flow builder
where you can build your flow.
-
You can continue to the following procedure to build your flow or return to the flow builder later.
To build your flow
-
If you're not already in the flow builder, do the following:
-
Sign in to the AWS Management Console using an IAM role with Amazon Bedrock permissions, and open the Amazon Bedrock console at
Getting Started with the AWS Management Console.
-
Select Amazon Bedrock Flows from the left navigation pane. Then, choose a flow in the Amazon Bedrock Flows section.
-
Choose Edit in flow builder.
-
In the flow builder section, the center pane displays a Flow input
node and a Flow output node. These are the input and output nodes for your flow.
-
To add and configure nodes
-
In the Flow builder pane, select Nodes.
-
Drag a node you want to use for the first step of your flow and drop it in the center pane.
-
The circles on the nodes are connection points. To connect your flow input node to the second node, drag a line from
the circle on the Flow input
node to the circle in the Input section of the node you just added.
-
Select the node you just added.
-
In the Configure section of the Flow builder pane, provide the configurations for the selected node and define names, data types, and expressions for the inputs and outputs of the node.
-
In the Flow builder pane, select Nodes.
-
Repeat steps to add and configure nodes the remaining nodes in your flow.
If you use a service role that Amazon Bedrock automatically created for you, the role will update with the proper permissions as you add nodes. If you use a custom service role however, you must add the proper permissions to the policy attached to your service role by referring to Create a service role for Amazon Bedrock Flows in Amazon Bedrock.
-
Connect the Output of the last node in your flow with the Input of the Flow output node.
You can have multiple Flow output nodes. To add additional flow output nodes,
drag the Flow output node and drop it next to the node where you want the flow to stop. Make sure to draw connections between the two nodes.
-
You can either continue to the next procedure to Test a flow in Amazon Bedrock or come back later. To continue to the next step, choose Save. To come back later, choose Save and exit.
Delete a node or a connection
During the process of building your flow, you might need to delete a node or remove node connections.
To delete a node
-
Select a node you want to delete.
-
In the Flow builder pane, choose the delete icon (
).
If you use a service role that Amazon Bedrock automatically created for you, the role will update with the proper permissions as you add nodes. If you delete nodes, however, the relevant permissions won't be deleted. We recommend that you delete the permissions that you no longer need by following the steps at Modifying a role.
- API
-
To create a flow, send a CreateFlow request (see link for request and response formats and field details) with an Agents for Amazon Bedrock build-time endpoint.
The following fields are required:
The following fields are optional:
While the definition
field is optional, it is required for the flow to be functional. You can choose to create a flow without the definition first and instead update the flow later.
For each node in your nodes
list, you specify the type of node in the type
field and provide the corresponding configuration of the node in the config
field. For details about the API structure of different types of nodes, see Node types in flow.
The following requirements apply to building a flow:
-
Your flow must have only one flow input node and at least one flow output node.
-
You can't include inputs for a flow input node.
-
You can't include outputs for a flow output node.
-
Every output in a node must be connected to an input in a downstream node (in the API, this is done through a FlowConnection with a FlowDataConnectionConfiguration).
-
Every condition (including the default one) in a condition node must be connected to a downstream node (in the API, this is done through a FlowConnection with a FlowConditionalConnectionConfiguration).
The following pointers apply to building a flow:
-
Begin by setting the data type for the output of the flow input node. This data type should match what you expect to send as the input when you invoke the flow.
-
When you define the inputs for a flow using expressions, check that the result matches the data type that you choose for the input.
-
If you include an iterator node, include a collector node downstream after you've sent the output through the nodes that you need. The collector node will return the outputs in an array.