BedrockAgentRuntimeClient.retrieve_and_generate_stream
rboto-bedrock-agent-runtime==0.4.0 · Service index · Types
Model summary (excerpt): Queries a knowledge base and generates responses based on the retrieved results, with output in streaming format. This API cannot be used with managed knowledge bases. Use AgenticRetrieveStream or Retrieve with managed knowledge bases. The CLI doesn't support streaming operations in Amazon Bedrock, including InvokeModelWithResponseStream . This operation requires permission for the...
Install and imports
from rboto import BedrockAgentRuntimeClient
from rboto_bedrock_agent_runtime.types import (
RetrieveAndGenerateConfiguration,
RetrieveAndGenerateInput,
RetrieveAndGenerateSessionConfiguration,
RetrieveAndGenerateStreamOutput,
UserContext,
)
Signature
async def retrieve_and_generate_stream(
*,
input: RetrieveAndGenerateInput,
session_id: str | None = None,
retrieve_and_generate_configuration: RetrieveAndGenerateConfiguration | None = None,
session_configuration: RetrieveAndGenerateSessionConfiguration | None = None,
user_context: UserContext | None = None,
) -> RetrieveAndGenerateStreamOutput: ...
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) |
|---|---|---|
input |
Yes | Contains the query to be made to the knowledge base. |
session_id |
No | The unique identifier of the session. When you first make a RetrieveAndGenerate request, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can't explicitly set the sessionId yourself. |
retrieve_and_generate_configuration |
No | Contains configurations for the knowledge base query and retrieval process. For more information, see Query configurations . |
session_configuration |
No | Contains details about the session with the knowledge base. |
user_context |
No | Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access. |
Output
RetrieveAndGenerateStreamOutput.
Typed response mapping, accessed as response["field"].
| Field | Type | Presence | References |
|---|---|---|---|
stream |
AsyncIterator[RetrieveAndGenerateStreamResponseOutput] |
Always present | RetrieveAndGenerateStreamResponseOutput |
session_id |
str |
Always present | — |
| 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.
Related types
RetrieveAndGenerateConfiguration, RetrieveAndGenerateInput, RetrieveAndGenerateSessionConfiguration, RetrieveAndGenerateStreamOutput, UserContext
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: RetrieveAndGenerateStreamOutput.
Consume with async for. Do not reuse a consumed stream.
Errors
Import from rboto_bedrock_agent_runtime.exceptions:
AccessDeniedError, BadGatewayError, ConflictError, DependencyFailedError, InternalServerError, ResourceNotFoundError, ServiceQuotaExceededError, 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.