Skip to content

invoke_model_with_bidirectional_stream

Operation

Async only

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

invoke_model_with_bidirectional_stream async

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.

It is possible for users to interrupt the model's response with a new prompt, which will halt the response speech. The model will retain contextual awareness of the conversation while pivoting to respond to the new prompt.

Parameters:

Name Type Description Default
request InvokeModelWithBidirectionalStreamOperationInput | InvokeModelWithBidirectionalStreamOperationInputDict | 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[InvokeModelWithBidirectionalStreamOperationInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
AsyncDuplexEventStream[InvokeModelWithBidirectionalStreamInput, InvokeModelWithBidirectionalStreamOutput, InvokeModelWithBidirectionalStreamOperationOutput]

An AsyncDuplexEventStream for bidirectional streaming.

Input

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

InvokeModelWithBidirectionalStreamOperationInputDict

Bases: TypedDict

Dictionary form of InvokeModelWithBidirectionalStreamOperationInput.

Attributes

model_id instance-attribute
model_id: Required[str]

The model ID or ARN of the model ID to use. Currently, only amazon.nova-sonic-v1:0 is supported.

InvokeModelWithBidirectionalStreamOperationInput dataclass

Bases: _SerdeShape

Dataclass for InvokeModelWithBidirectionalStreamOperationInput structure.

Attributes

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

The model ID or ARN of the model ID to use. Currently, only amazon.nova-sonic-v1:0 is supported.

Output

This operation returns an AsyncDuplexEventStream for bidirectional streaming.

Event Stream Structure

Input Event Type

InvokeModelWithBidirectionalStreamInput

Output Event Type

InvokeModelWithBidirectionalStreamOutput

Initial Response Structure

InvokeModelWithBidirectionalStreamOperationOutput dataclass

Bases: _SerdeShape

Dataclass for InvokeModelWithBidirectionalStreamOperationOutput structure.

Attributes
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.