AWS Bedrock

Use AWS Bedrock foundation models with Agno agents.

Use AWS Bedrock to access various foundation models on AWS. Manage your access to models on the portal.

See all the AWS Bedrock foundation models. Not all Bedrock models support all features. See the supported features for each model.

We recommend experimenting to find the best-suited model for your use case. Here are some general recommendations:

  • For a Mistral model with generally good performance, look at mistral.mistral-large-2402-v1:0.
  • For Amazon Nova models, use amazon.nova-pro-v1:0 for general-purpose tasks.
  • For Claude models, see our Claude integration.

Installation

uv pip install -U boto3 agno

Install aioboto3 when Agno creates its own async Bedrock client:

uv pip install aioboto3

Authentication

AWS Bedrock supports three authentication methods:

Set your AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_REGION environment variables.

Get your keys from here.

export AWS_ACCESS_KEY_ID=***
export AWS_SECRET_ACCESS_KEY=***
export AWS_REGION=***

Or pass them directly to the model:

from agno.agent import Agent
from agno.models.aws import AwsBedrock

agent = Agent(
    model=AwsBedrock(
        id="mistral.mistral-large-2402-v1:0",
        aws_access_key_id="your-access-key",
        aws_secret_access_key="your-secret-key",
        aws_region="us-east-1"
    )
)

Method 2: SSO Authentication

Use SSO authentication by leveraging your current AWS profile's authentication:

from agno.agent import Agent
from agno.models.aws import AwsBedrock

agent = Agent(
    model=AwsBedrock(
        id="mistral.mistral-large-2402-v1:0",
        aws_sso_auth=True,
        aws_region="us-east-1"
    )
)

Method 3: Boto3 Session

Use a pre-configured boto3 Session for advanced authentication scenarios (including SSO, role assumption, etc.):

from boto3.session import Session
from agno.agent import Agent
from agno.models.aws import AwsBedrock

# Create a boto3 session with your preferred authentication
session = Session(
    aws_access_key_id="your-access-key",
    aws_secret_access_key="your-secret-key",
    region_name="us-east-1"
)

agent = Agent(
    model=AwsBedrock(
        id="mistral.mistral-large-2402-v1:0",
        session=session
    )
)

The authentication methods are checked in this order: Session → SSO → Access Key/Secret Key. The first available method will be used.

Example

Use AwsBedrock with your Agent:

from agno.agent import Agent
from agno.models.aws import AwsBedrock

agent = Agent(
    model=AwsBedrock(id="mistral.mistral-large-2402-v1:0"),
    markdown=True
)

# Print the response on the terminal
agent.print_response("Share a 2 sentence horror story.")
View more examples here.

Caller-owned async clients

You can supply an initialized, already-entered async Bedrock Runtime client. Agno reuses it and does not enter or close it; keep it open for every agent call. For example, with aioboto3 installed and the AWS credentials above configured:

async_agent.py
import asyncio

import aioboto3
from agno.agent import Agent
from agno.models.aws import AwsBedrock


async def main():
    session = aioboto3.Session()
    async with session.client("bedrock-runtime", region_name="us-east-1") as client:
        agent = Agent(model=AwsBedrock(
            id="amazon.nova-pro-v1:0", async_client=client,
        ))
        await agent.aprint_response("Share a two-sentence story.")


if __name__ == "__main__":
    asyncio.run(main())

Pass the client yielded by async with, not the unentered context manager. A synchronous boto3 client belongs in client=. Supplying an async client avoids Agno's aioboto3 client factory; get_async_client() always creates a new owned context manager and is not an accessor for the injected client.

Parameters

ParameterTypeDefaultDescription
idstr"mistral.mistral-small-2402-v1:0"The specific model ID used for generating responses.
namestr"AwsBedrock"The name identifier for the model.
providerstr"AwsBedrock"The provider of the model.
aws_access_key_idOptional[str]NoneThe AWS access key ID for authentication. Can also be set via AWS_ACCESS_KEY_ID environment variable.
aws_secret_access_keyOptional[str]NoneThe AWS secret access key for authentication. Can also be set via AWS_SECRET_ACCESS_KEY environment variable.
aws_session_tokenOptional[str]NoneThe AWS session token for temporary credentials. Can also be set via AWS_SESSION_TOKEN environment variable.
aws_regionOptional[str]NoneThe AWS region to use for API requests. Can also be set via AWS_REGION environment variable.
sessionOptional[Session]NoneA boto3 Session object for advanced authentication scenarios (SSO, role assumption, etc.).
aws_sso_authOptional[bool]FalseRemoves the need for an access and secret access key by leveraging the current profile's authentication.
max_tokensOptional[int]NoneThe maximum number of tokens to generate in the response.
temperatureOptional[float]NoneThe sampling temperature to use. Higher values like 0.8 make the output more random, while lower values like 0.2 make it more focused and deterministic.
top_pOptional[float]NoneThe nucleus sampling parameter. The model considers the results of the tokens with top_p probability mass.
stop_sequencesOptional[List[str]]NoneA list of sequences where the API will stop generating further tokens.
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters for the request, provided as a dictionary.
append_trailing_user_messageOptional[bool]NoneAppend a trailing user message when the conversation ends with an assistant message. The default depends on whether the model supports assistant message prefill.
trailing_user_message_contentstr"continue"Content of the appended trailing user message.
clientOptional[AwsClient]NoneA pre-configured AWS client instance.
async_clientOptional[Any]NoneAlready-entered async Bedrock Runtime client. The caller owns its lifetime and cleanup.

AwsBedrock is a subclass of the Model class and has access to the same params.