yera.models.interfaces.llms.aws_bedrock

Module containing the interface to AWS bedrock LLMs.

Symbols

class AwsBedrockLLM — Interface to AWS Bedrock LLM models.

AwsBedrockLLM

Interface to AWS Bedrock LLM models.

This class provides a wrapper around the AWS Bedrock runtime client, enabling interactions with various LLM models available through Bedrock (AWS Bedrock Claude, Qwen, OpenAI, DeepSeek, Google Gemini, and others). It supports both standard chat completions and structured output generation for models that support it.

The class automatically detects whether the selected model natively supports structured outputs or requires a tool-use fallback.

Attributes

config
type: LLMConfig

Configuration settings for the LLM including model_id and inference parameters.

connection
type: AWSConnection

AWS connection configuration including credentials and region information.

native_struct
type: bool

Whether the selected model supports native structured output generation.

client
type: BaseClient

Lazy-initialized AWS Bedrock runtime client instance.

Methods

start — Initialise the AWS Bedrock API client.
stop — Shut down and clear the AWS Bedrock API client.
chat — Stream a chat response through the configured AWS transport.
make_struct — Stream a structured response through the configured AWS transport.

AwsBedrockLLM.start

start() → None

Initialise the AWS Bedrock API client.

Creates and stores an AWS Bedrock client instance using the configured connection settings. This method must be called before making any API requests via the client property.

AwsBedrockLLM.stop

stop() → None

Shut down and clear the AWS Bedrock API client.

Releases the AWS Bedrock client instance by setting it to None. After calling this method, start() must be called again before further API requests can be made.

AwsBedrockLLM.chat

chat(
    messages: list[Message],
    reasoning_level: ReasoningLevel | None = None,
    **overrides,
) → Iterator[LLMToken]

Stream a chat response through the configured AWS transport.

Responses models use Bedrock Runtime's OpenAI-compatible endpoint. Other Bedrock models use the Converse API.

Parameters

messages
type: list[Message]

Workspace conversation history.

reasoning_level
type: ReasoningLevel | None = None

Per-call reasoning override.

**overrides
type: str | int | float | bool

Per-call inference overrides.

AwsBedrockLLM.make_struct

make_struct(
    messages: list[Message],
    reasoning_level: ReasoningLevel | None = None,
    **overrides,
) → Iterator[LLMToken]

Stream a structured response through the configured AWS transport.

Responses models use OpenAI-compatible strict JSON Schema. Converse models use Bedrock's native structured-output configuration.

Parameters

messages
type: list[Message]

Workspace conversation history.

cls
type: type[TStruct]

Struct class defining the required output.

reasoning_level
type: ReasoningLevel | None = None

Per-call reasoning override.

**overrides
type: str | int | float | bool

Per-call inference overrides.