Skip to main content

Parameters

ParameterTypeDefaultDescription
model_nameBedrockModelNameNoneThe name of the Bedrock model to use. List of model names available here
providerLiteral['bedrock'] | Provider[BaseClient]'bedrock'The provider to use for authentication and API access. Can be either the string ‘bedrock’ or an instance of Provider[BaseClient]. If not provided, a new provider will be created using the other parameters
profileModelProfileSpec | NoneNoneThe model profile to use. Defaults to a profile picked by the provider based on the model name
settingsModelSettings | NoneNoneModel-specific settings that will be used as defaults for this model

Functions

__init__

Initialize a Bedrock model. Parameters:
  • model_name (BedrockModelName): The name of the Bedrock model to use. List of model names available here
  • provider (Literal[‘bedrock’] | Provider[BaseClient]): The provider to use for authentication and API access. Can be either the string ‘bedrock’ or an instance of Provider[BaseClient]. If not provided, a new provider will be created using the other parameters
  • profile (ModelProfileSpec | None): The model profile to use. Defaults to a profile picked by the provider based on the model name
  • settings (ModelSettings | None): Model-specific settings that will be used as defaults for this model

base_url

Get the base URL for the provider API. Returns:
  • str: The base URL for the provider API

model_name

Get the model name. Returns:
  • str: The model name

system

Get the model provider. Returns:
  • str: The model provider

request

Make a request to the model. Parameters:
  • messages (list[ModelMessage]): The messages to send to the model
  • model_settings (ModelSettings | None): Model-specific settings
  • model_request_parameters (ModelRequestParameters): Request parameters
Returns:
  • ModelResponse: The model response

request_stream

Make a request to the model and return a streaming response. Parameters:
  • messages (list[ModelMessage]): The messages to send to the model
  • model_settings (ModelSettings | None): Model-specific settings
  • model_request_parameters (ModelRequestParameters): Request parameters
Returns:
  • AsyncIterator[StreamedResponse]: An async iterator of streamed responses

_get_tools

Get the tools for the model request. Parameters:
  • model_request_parameters (ModelRequestParameters): Request parameters
Returns:
  • list[ToolTypeDef]: The tools for the request

_map_tool_definition

Map a tool definition to Bedrock format. Parameters:
  • f (ToolDefinition): The tool definition to map
Returns:
  • ToolTypeDef: The mapped tool definition

_process_response

Process a non-streamed response, and prepare a message to return. Parameters:
  • response (ConverseResponseTypeDef): The response from Bedrock
Returns:
  • ModelResponse: The processed model response

_messages_create

Create a messages request to the Bedrock API. Parameters:
  • messages (list[ModelMessage]): The messages to send to the model
  • stream (bool): Whether to stream the response
  • model_settings (BedrockModelSettings | None): Bedrock-specific model settings
  • model_request_parameters (ModelRequestParameters): Request parameters
Returns:
  • ConverseResponseTypeDef | ConverseStreamResponseTypeDef: The response from Bedrock

_map_inference_config

Map model settings to Bedrock inference configuration. Parameters:
  • model_settings (ModelSettings | None): Model settings
Returns:
  • InferenceConfigurationTypeDef: The mapped inference configuration

_map_tool_config

Map tool configuration for Bedrock. Parameters:
  • model_request_parameters (ModelRequestParameters): Request parameters
Returns:
  • ToolConfigurationTypeDef | None: The mapped tool configuration

_map_messages

Map messages to Bedrock format. Parameters:
  • messages (list[ModelMessage]): The messages to map
Returns:
  • tuple[list[SystemContentBlockTypeDef], list[MessageUnionTypeDef]]: The mapped messages

_map_user_prompt

Map a user prompt to Bedrock format. Parameters:
  • part (UserPromptPart): The user prompt part to map
  • document_count (Iterator[int]): Iterator for document counting
Returns:
  • list[MessageUnionTypeDef]: The mapped user prompt

_map_tool_call

Map a tool call to Bedrock format. Parameters:
  • t (ToolCallPart): The tool call part to map
Returns:
  • ContentBlockOutputTypeDef: The mapped tool call
I