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

__init__ — Initialize a Bedrock interface without starting its runtime client.
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.__init__

__init__(
    config: LLMConfig,
    connection: AWSConnection,
    overrides: dict,
) → None

Initialize a Bedrock interface without starting its runtime client.

Parameters

config
type: LLMConfig

Model identity, capabilities, and default inference settings.

connection
type: AWSConnection

AWS connection used when the client is started.

overrides
type: dict

Inference values to apply over the model defaults.

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.

Raises

ValueError

If the selected transport cannot represent the requested structured-output schema or reasoning settings.

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.

Raises

ValueError

If the selected transport cannot represent the requested structured-output schema or reasoning settings.