Skip to content

invoke_flow

Operation

Async only

This operation uses an event stream, so only the asynchronous client supports it.

invoke_flow async

invoke_flow(request: InvokeFlowInput | InvokeFlowInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[InvokeFlowInputDict]) -> AsyncOutputEventStream[FlowResponseStream, InvokeFlowOutput]

Invokes an alias of a flow to run the inputs that you specify and return the output of each node as a stream. If there's an error, the error is returned. For more information, see Test a flow in Amazon Bedrock in the Amazon Bedrock User Guide.

Note

The CLI doesn't support streaming operations in Amazon Bedrock, including InvokeFlow.

Parameters:

Name Type Description Default
request InvokeFlowInput | InvokeFlowInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[InvokeFlowInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
AsyncOutputEventStream[FlowResponseStream, InvokeFlowOutput]

An AsyncOutputEventStream for server-to-client streaming.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

InvokeFlowInputDict

Bases: TypedDict

Dictionary form of InvokeFlowInput.

Attributes

enable_trace instance-attribute
enable_trace: bool | None

Specifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see Track each step in your prompt flow by viewing its trace in Amazon Bedrock.

execution_id instance-attribute
execution_id: str | None

The unique identifier for the current flow execution. If you don't provide a value, Amazon Bedrock creates the identifier for you.

flow_alias_identifier instance-attribute
flow_alias_identifier: Required[str]

The unique identifier of the flow alias.

flow_identifier instance-attribute
flow_identifier: Required[str]

The unique identifier of the flow.

inputs instance-attribute

A list of objects, each containing information about an input into the flow.

model_performance_configuration instance-attribute
model_performance_configuration: ModelPerformanceConfiguration | ModelPerformanceConfigurationDict | None

Model performance settings for the request.

InvokeFlowInput dataclass

Bases: _SerdeShape

Dataclass for InvokeFlowInput structure.

Attributes

enable_trace class-attribute instance-attribute
enable_trace: bool | None = ...

Specifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see Track each step in your prompt flow by viewing its trace in Amazon Bedrock.

execution_id class-attribute instance-attribute
execution_id: str | None = ...

The unique identifier for the current flow execution. If you don't provide a value, Amazon Bedrock creates the identifier for you.

flow_alias_identifier class-attribute instance-attribute
flow_alias_identifier: str | None = ...

The unique identifier of the flow alias.

flow_identifier class-attribute instance-attribute
flow_identifier: str | None = ...

The unique identifier of the flow.

inputs class-attribute instance-attribute
inputs: list[FlowInput] | None = ...

A list of objects, each containing information about an input into the flow.

model_performance_configuration class-attribute instance-attribute
model_performance_configuration: ModelPerformanceConfiguration | None = ...

Model performance settings for the request.

Output

This operation returns an AsyncOutputEventStream for server-to-client streaming.

Event Stream Structure

Output Event Type

FlowResponseStream

Initial Response Structure

InvokeFlowOutput dataclass

Bases: _SerdeShape

Dataclass for InvokeFlowOutput structure.

Attributes
execution_id class-attribute instance-attribute
execution_id: str | None = ...

The unique identifier for the current flow execution.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.