Skip to content

BedrockRuntimeClient.invoke_model_with_bidirectional_stream

rboto-bedrock-runtime==0.4.0 · Service index · Types

Model summary (excerpt): 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...

Install and imports

python -m pip install "rboto[bedrock-runtime]==0.4.0"
from rboto import BedrockRuntimeClient
from collections.abc import AsyncIterator
from rboto_bedrock_runtime.types import (
    InvokeModelWithBidirectionalStreamInput,
    InvokeModelWithBidirectionalStreamOutput,
)

Signature

async def invoke_model_with_bidirectional_stream(
    *,
    model_id: str,
    body: AsyncIterator[InvokeModelWithBidirectionalStreamInput],
) -> InvokeModelWithBidirectionalStreamOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
model_id Yes The model ID or ARN of the model ID to use. Currently, only amazon.nova-sonic-v1:0 is supported.
body Yes The prompt and inference parameters in the format specified in the BidirectionalInputPayloadPart in the header. You must provide the body in JSON format. To see the format and content of the request and response bodies for different models, refer to Inference parameters . For more information, see Run inference in the Bedrock User Guide.

Output

InvokeModelWithBidirectionalStreamOutput.

Typed response mapping, accessed as response["field"].

Field Type Presence References
body AsyncIterator[InvokeModelWithBidirectionalStreamEventOutput] Always present InvokeModelWithBidirectionalStreamEventOutput

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

InvokeModelWithBidirectionalStreamInput, InvokeModelWithBidirectionalStreamOutput

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

Output streams: InvokeModelWithBidirectionalStreamOutput.

Consume with async for. Do not reuse a consumed stream.

Input event streams accept the declared AsyncIterator of typed events.

Errors

Import from rboto_bedrock_runtime.exceptions:

AccessDeniedError, InternalServerError, ModelError, ModelNotReadyError, ModelStreamError, ModelTimeoutError, ResourceNotFoundError, ServiceQuotaExceededError, ServiceUnavailableError, ThrottlingError, ValidationError.

Stream decoding may also raise the linked modeled event errors.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model