

# References/Advanced
<a name="references"></a>

Find reference materials, tutorials, and troubleshooting resources for Amazon Bedrock:


| Resource | Description | 
| --- | --- | 
| [Key terminology](key-definitions.md) | Essential generative AI and Amazon Bedrock terminology | 
| [Using Amazon Bedrock with an AWS SDK](sdk-general-information-section.md) | SDKs and programming language support | 
| [Troubleshooting Amazon Bedrock API Error Codes](troubleshooting-api-error-codes.md) | Common API errors and resolutions | 
| [Detailed Getting Started using Console and API](detailed-getting-started.md) | Detailed console and API setup guides | 
| [Tutorial: Create a flow that processes mortgage applications](getting-started-mortgage-flow.md) | Tutorial: Build a mortgage processing flow | 
| [Document history for the Amazon Bedrock User Guide](doc-history.md) | Document revision history | 

# Key terminology
<a name="key-definitions"></a>

This chapter explains terminology that will help you understand what Amazon Bedrock offers and how it works. Read through the following list to understand generative AI terminology and Amazon Bedrock's fundamental capabilities:
+ **Foundation model (FM)** – An AI model with a large number of parameters and trained on a massive amount of diverse data. A foundation model can generate a variety of responses for a wide range of use cases. Foundation models can generate text or image, and can also convert input into *embeddings*. For more information about foundation models, see [Supported foundation models in Amazon Bedrock](models-supported.md).
+ **Base model** – A foundation model that is packaged by a provider and ready to use. Amazon Bedrock offers a variety of industry-leading foundation models from leading providers. For more information, see [Supported foundation models in Amazon Bedrock](models-supported.md).
+ **Model inference** – The process of a foundation model generating an output (response) from a given input (prompt). For more information, see [Submit prompts and generate responses with model inference](inference.md).
+ **Prompt** – An input provided to a model to guide it to generate an appropriate response or output for the input. For example, a text prompt can consist of a single line for the model to respond to, or it can detail instructions or a task for the model to perform. The prompt can contain the context of the task, examples of outputs, or text for a model to use in its response. Prompts can be used to carry out tasks such as classification, question answering, code generation, creative writing, and more. For more information, see [Prompt engineering concepts](prompt-engineering-guidelines.md).
+ **Token** – A sequence of characters that a model can interpret or predict as a single unit of meaning. For example, with text models, a token could correspond not just to a word, but also to a part of a word with grammatical meaning (such as "-ed"), a punctuation mark (such as "?"), or a common phrase (such as "a lot").
+ **Model parameters** – Values that define a model and its behavior in interpreting input and generating responses. Model parameters are controlled and updated by providers. You can also update model parameters to create a new model through the process of *model customization*.
+ **Inference parameters** – Values that can be adjusted during **model inference** to influence a response. Inference parameters can affect how varied responses are and can also limit the length of a response or the occurrence of specified sequences. For more information and definitions of specific inference parameters, see [Influence response generation with inference parameters](inference-parameters.md).
+ **Playground** – A user-friendly graphical interface in the AWS Management Console in which you can experiment with running model inference to familiarize yourself with Amazon Bedrock. Use the playground to test out the effects of different models, configurations, and inference parameters on the responses generated for different prompts that you enter. For more information, see [Generate responses in the console using playgrounds](playgrounds.md).
+ **Embedding** – The process of condensing information by transforming input into a vector of numerical values, known as the **embeddings**, in order to compare the similarity between different objects by using a shared numerical representation. For example, sentences can be compared to determine the similarity in meaning, images can be compared to determine visual similarity, or text and image can be compared to see if they're relevant to each other. You can also combine text and image inputs into an averaged embeddings vector if it's relevant to your use case. For more information, see [Submit prompts and generate responses with model inference](inference.md) and [Retrieve data and generate AI responses with Amazon Bedrock Knowledge Bases](knowledge-base.md).
+ **Orchestration** – The process of coordinating between foundation models and enterprise data and applications in order to carry out a task. For more information, see [Automate tasks in your application using AI agents](agents.md).
+ **Agent** – An application that carries out orchestrations through cyclically interpreting inputs and producing outputs by using a foundation model. An agent can be used to carry out customer requests. For more information, see [Automate tasks in your application using AI agents](agents.md).
+ **Retrieval augmented generation (RAG)** – The process involves:

  1. Querying and retrieving information from a data source

  1. Augmenting a prompt with this information to provide better context to the foundation model

  1. Obtaining a better response from the foundation model using the additional context

  For more information, see [Retrieve data and generate AI responses with Amazon Bedrock Knowledge Bases](knowledge-base.md).
+ **Model customization** – The process of using training data to adjust the model parameter values in a base model in order to create a **custom model**. Examples of model customization include **Fine-tuning**, which uses labeled data (inputs and corresponding outputs) to adjust model parameters. For more information about model customization techniques available in Amazon Bedrock, see [Customize your model to improve its performance for your use case](custom-models.md).
+ **Hyperparameters** – Values that can be adjusted for **model customization** to control the training process and, consequently, the output custom model. For more information and definitions of specific hyperparameters, see [Custom model hyperparameters](custom-models-hp.md).
+ **Model evaluation** – The process of evaluating and comparing model outputs in order to determine the model that is best suited for a use case. For more information, see [Evaluate the performance of Amazon Bedrock resources](evaluation.md).
+ **Provisioned Throughput** – A level of throughput that you purchase for a base or custom model in order to increase the amount and/or rate of tokens processed during model inference. When you purchase Provisioned Throughput for a model, a **provisioned model** is created that can be used to carry out model inference. For more information, see [Increase model invocation capacity with Provisioned Throughput in Amazon Bedrock](prov-throughput.md).

# Using Amazon Bedrock with an AWS SDK
<a name="sdk-general-information-section"></a>

AWS software development kits (SDKs) are available for many popular programming languages. Each SDK provides an API, code examples, and documentation that make it easier for developers to build applications in their preferred language.


| SDK documentation | Code examples | 
| --- | --- | 
| [AWS SDK for C\$1\$1](https://docs.aws.amazon.com/sdk-for-cpp) | [AWS SDK for C\$1\$1 code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/cpp) | 
| [AWS CLI](https://docs.aws.amazon.com/cli) | [AWS CLI code examples](https://docs.aws.amazon.com/code-library/latest/ug/cli_2_code_examples.html) | 
| [AWS SDK for Go](https://docs.aws.amazon.com/sdk-for-go) | [AWS SDK for Go code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/gov2) | 
| [AWS SDK for Java](https://docs.aws.amazon.com/sdk-for-java) | [AWS SDK for Java code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2) | 
| [AWS SDK for JavaScript](https://docs.aws.amazon.com/sdk-for-javascript) | [AWS SDK for JavaScript code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3) | 
| [AWS SDK for Kotlin](https://docs.aws.amazon.com/sdk-for-kotlin) | [AWS SDK for Kotlin code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin) | 
| [AWS SDK for .NET](https://docs.aws.amazon.com/sdk-for-net) | [AWS SDK for .NET code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3) | 
| [AWS SDK for PHP](https://docs.aws.amazon.com/sdk-for-php) | [AWS SDK for PHP code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/php) | 
| [AWS Tools for PowerShell](https://docs.aws.amazon.com/powershell) | [AWS Tools for PowerShell code examples](https://docs.aws.amazon.com/code-library/latest/ug/powershell_5_code_examples.html) | 
| [AWS SDK for Python (Boto3)](https://docs.aws.amazon.com/pythonsdk) | [AWS SDK for Python (Boto3) code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python) | 
| [AWS SDK for Ruby](https://docs.aws.amazon.com/sdk-for-ruby) | [AWS SDK for Ruby code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/ruby) | 
| [AWS SDK for Rust](https://docs.aws.amazon.com/sdk-for-rust) | [AWS SDK for Rust code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1) | 
| [AWS SDK for SAP ABAP](https://docs.aws.amazon.com/sdk-for-sapabap) | [AWS SDK for SAP ABAP code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/sap-abap) | 
| [AWS SDK for Swift](https://docs.aws.amazon.com/sdk-for-swift) | [AWS SDK for Swift code examples](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/swift) | 

**Example availability**  
Can't find what you need? Request a code example by using the **Provide feedback** link at the bottom of this page.

# Troubleshooting Amazon Bedrock API Error Codes
<a name="troubleshooting-api-error-codes"></a>

This section provides detailed information about the common errors you might encounter when using Amazon Bedrock APIs, the cause of the error, and the solution for resolving the error.

## AccessDeniedException
<a name="ts-access-denied"></a>

**HTTP Status Code: **403

**Cause: **You do not have sufficient permissions to perform the requested action.

**Solution:**
+ Verify that your IAM user or role has the necessary permissions for the action you are attempting.
+ If you are using temporary security credentials, ensure they haven't expired.

## FTUFormNotFilled
<a name="ts-ftu-form"></a>

**HTTP Status Code: **404

**Cause: **Model use case details have not been submitted for this account

**Solution:**
+ Fill out the Anthropic use case details form before using the model

## IncompleteSignature
<a name="ts-incomplete-signature"></a>

**HTTP Status Code: **400

**Cause:** The request signature does not conform to AWS standards.

**Solution:**
+ Ensure you are using an AWS SDK version that supports Amazon Bedrock.
+ Verify that your AWS access key ID and secret key are correctly configured.
+ If you are manually signing requests, we suggest double-checking your signature calculation process.

## InternalFailure
<a name="ts-internal-failure"></a>

**HTTP Status Code: **500

**Cause: **The request processing has failed due to a server error

**Solution:**
+ We suggest employing AWS recommended approach of using [retries with exponential backoff](https://docs.aws.amazon.com//prescriptive-guidance/latest/cloud-design-patterns/retry-backoff.html) and random [jitter](https://aws.amazon.com/builders-library/timeouts-retries-and-backoff-with-jitter/) for improved reliability.
+ If the issue persists, please contact [AWS Support Center](https://aws.amazon.com/support) and provide details about your request and the error you are encountering.

## InvalidAction
<a name="ts-invalid-action"></a>

**HTTP Status Code: **400

**Cause: **The action or operation requested is invalid

**Solution:**
+ We suggest double-checking the spelling and formatting of the action name in your request.
+ Verify that the action calling is supported by Amazon Bedrock and is correctly documented as shown in [Amazon Bedrock API Reference.](https://docs.aws.amazon.com//bedrock/latest/APIReference/API_Operations.html)
+ Ensure you are using the most up-to-date version of the AWS SDK or CLI.

## InvalidClientTokenId
<a name="ts-invalid-client-token"></a>

**HTTP Status Code: **403

**Cause: **The X.509 certificate or AWS access key ID provided does not exist in our records.

**Solution:**
+ Verify that you are using the correct AWS access key ID.
+ If you recently created new access keys, ensure you are using the new credentials and not the old ones.

## AWS Marketplace Agreement Failed within 15 minutes
<a name="ts-mp-agreement-failed"></a>

**HTTP Status Code: **403

**Cause: **The AWS Marketplace Agreement failed due to an underlying issue.

**Solution:**
+ Review the error message and remediate the underlying issue. Common underlying issues are invalid payment error and restricted geo-location.
+ For invalid payment error, please review [Restriction on credit and debit card purchases for AISPL customers using AWS Marketplace](https://aws-blogs-prod.amazon.com/awsmarketplace/restriction-on-credit-and-debit-card-purchases-for-aispl-customers-using-aws-marketplace/) and [INVALID\$1PAYMENT\$1INSTRUMENT after requesting model access in Amazon Bedrock.](https://repost.aws/questions/QU0UOsutrWSSS4nOqgHcIUJg/invalid-payment-instrument-after-requesting-model-access-in-amazon-bedrock).

## AWS Marketplace Agreement Pending after 15 minutes
<a name="ts-mp-agreement-pending"></a>

**HTTP Status Code: **403

**Cause: **The AWS Marketplace Agreement has not succeeded and it has been 15 minutes since the request was made.

**Solution:**
+ Try the request again every 15 minutes. If the issue persists, please contact [AWS Support Center](https://aws.amazon.com/support) and provide details about your request and the error you are encountering.

## MPAgreementBeingCreated
<a name="ts-mp-agreement-created"></a>

**HTTP Status Code: **403

**Cause: **Your account is not authorized to access this model. Your AWS Marketplace subscription for this model is still being processed

**Solution:**
+ Try again after 15 minutes

## NotAuthorized
<a name="ts-not-authorized"></a>

**HTTP Status Code: **400

**Cause: **You do not have permission to perform this action.

**Solution:**
+ Review your IAM permissions and ensure you have the necessary rights to perform the requested action on Amazon Bedrock resources.
+ If you are using an IAM role, verify that the role has the appropriate permissions and trust relationships.
+ Check for any organizational policies or service control policies that might be restricting your access.

## RequestExpired
<a name="ts-request-expired"></a>

**HTTP Status Code: **400

**Cause: **The request is no longer valid due to expired timestamps.

**Solution:**
+ Ensure your system clock is correctly synchronized with a reliable time source.
+ If you are making requests from different time zones, be aware of potential timestamp discrepancies.

## ServiceUnavailable
<a name="ts-service-unavailable"></a>

**HTTP Status Code: **503

**Cause: **The service is temporarily unable to handle the request. 503 errors indicate that the service is experiencing high demand or temporary capacity constraints. This is not related to your account-level quotas or rate limits (which return 429 ThrottlingException).

**Solution:**
+ We suggest employing AWS recommended approach of using [retries with exponential backoff](https://docs.aws.amazon.com//prescriptive-guidance/latest/cloud-design-patterns/retry-backoff.html) and random [jitter](https://aws.amazon.com/builders-library/timeouts-retries-and-backoff-with-jitter/) for improved reliability.
+ Consider switching to a different AWS Region if the issue persists in your current Region. Different Regions may have varying levels of load and availability.
+ [Use Cross-Region inference](https://docs.aws.amazon.com//bedrock/latest/userguide/cross-region-inference.html) to seamlessly manage unplanned traffic bursts by utilizing compute across different AWS Regions.
+ If you have high throughput requirements, we suggest exploring [Provisioned Throughput](https://docs.aws.amazon.com//bedrock/latest/userguide/prov-throughput.html) for your use case.

**Best practices**
+ Ensure your application can handle 503 status codes appropriately in your error handling and retry logic.
+ Check the AWS Service Health Dashboard for any announced issues or scheduled maintenance that might affect the service.

If you experience frequent 503 errors or if they significantly impact your operations, please contact [AWS Support](https://aws.amazon.com/support)for further assistance and guidance tailored to your specific use case.

## ThrottlingException
<a name="ts-throttling-exception"></a>

**HTTP Status Code: **429

**Cause: **The request was denied due to exceeding the account quotas for Amazon Bedrock.

**Solution:**
+ Check the Amazon Bedrock service quotas in the [Amazon Bedrock service quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#limits_bedrock) console to learn about the limits allotted to your account.
+ We suggest employing AWS recommended approach of using [retries with exponential backoff.](https://docs.aws.amazon.com//prescriptive-guidance/latest/cloud-design-patterns/retry-backoff.html) and random [jitter](https://aws.amazon.com/builders-library/timeouts-retries-and-backoff-with-jitter/) for improved reliability.
+ If you have high throughput requirements, we suggest exploring [Provisioned Throughput](https://docs.aws.amazon.com//bedrock/latest/userguide/prov-throughput.html) for your use case.
+ Request for quota increase by contacting your account manager or [AWS Support](https://aws.amazon.com/support) if your workload traffic exceeds your account quotas.

## ValidationError
<a name="ts-validation-error"></a>

**HTTP Status Code: **400

**Cause: **The input fails to satisfy the constraints specified by Amazon Bedrock.

**Solution:**
+ Review the API documentation to ensure all required parameters are included and formatted correctly.
+ Check that your input values are within the allowed ranges or conform to the expected patterns.
+ We suggest paying attention to any specific validation rules mentioned in the API reference for the action you are using.

## ResourceNotFound
<a name="ts-resource-not-found"></a>

**HTTP Status Code: **404

**Cause: **The requested resource could not be found.

**Solution:**
+ Verify the correctness of model ID, endpoint name, or other resource identifiers in your request.
+ Please implement a fallback mechanism to use alternative models or endpoints when a primary resource is not found.

**Best practices**
+ Use [ListFoundationModels](https://docs.aws.amazon.com//bedrock/latest/APIReference/API_ListFoundationModels.html) to learn about the available Amazon Bedrock foundation models that you can use.
+ We suggest implementing a periodic synchronization process to update your local resource catalog.

If you continue to experience issues after trying these solutions, contact [AWS Support](https://aws.amazon.com/support)for further assistance and guidance tailored to your specific use case.

## Connection timeout or reset when calling Amazon Bedrock APIs
<a name="ts-connection-timeout"></a>

**Symptom: **API calls fail with connection resets or timeouts, especially for long-running requests such as streaming or extended inference, when traffic goes through NAT Gateways, VPC endpoints, or Network Load Balancers.

**Cause: **NAT Gateways, interface VPC endpoints, and Network Load Balancers have a fixed idle connection timeout of 350 seconds. If a TCP connection remains idle longer than this period, the connection is dropped. The client receives a TCP RST packet or the request times out.

**Solution:**

Enable TCP keep-alive to send periodic probes that prevent the connection from going idle. For more information, see [Implementing long-running TCP Connections within VPC networking](https://aws.amazon.com/blogs/networking-and-content-delivery/implementing-long-running-tcp-connections-within-vpc-networking/) in the AWS Networking & Content Delivery Blog.

If you continue to experience connection issues after enabling TCP keep-alive, contact [AWS Support](https://aws.amazon.com/support) for further assistance.

# Detailed Getting Started using Console and API
<a name="detailed-getting-started"></a>

Content coming soon.

# Get started in the Amazon Bedrock console
<a name="getting-started-console"></a>

This section describes how to use the [playgrounds](playgrounds.md) in the AWS console to submit a text prompt to an Amazon Bedrock foundation model (FM) and generate a text or image response. Before you run the following examples, you should check that you have fulfilled the following prerequisites:

**Prerequisites**
+ You have an AWS account and have permissions to access a role in that account with the necessary permissions for Amazon Bedrock. Otherwise, follow the steps at [Quickstart](getting-started.md).
+ You're in the US East (N. Virginia) (us-east-1) Region. To change Regions, choose the Region name at the top right of the console, next to your IAM role. Then select US East (N. Virginia) (us-east-1).

**Topics**
+ [Explore the text playground](#getting-started-text)
+ [Explore the image playground](#getting-started-image)

## Explore the text playground
<a name="getting-started-text"></a>

The following example demonstrates how to use the text playground:

1. Sign in to the AWS Management Console with an IAM identity that has permissions to use the Amazon Bedrock console. Then, open the Amazon Bedrock console at [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock).

1. From the left navigation pane, choose **Text** under **Playgrounds**.

1. Choose **Select model** and select a provider and model. For this example, we will select **Amazon Titan Text G1 - Lite**. Then choose **Apply**

1. Select a default prompt from below the text panel, or enter a prompt into the text panel, such as **Describe the purpose of a "hello world" program in one line**.

1. Choose **Run** to run inference on the model. The generated text appears below your prompt in the text panel.

## Explore the image playground
<a name="getting-started-image"></a>

The following example demonstrates how to use the image playground.

1. Sign in to the AWS Management Console with an IAM identity that has permissions to use the Amazon Bedrock console. Then, open the Amazon Bedrock console at [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock).

1. From the left navigation pane, choose **Image** under **Playgrounds**.

1. Choose **Select model** and select a provider and model. For this example, we will select **Amazon Titan Image Generator G1 V1**. Then choose **Apply**

1. Select a default prompt from below the text panel, or enter a prompt into the text panel, such as **Generate an image of happy cats**.

1. In the **Configurations** pane, change the **Number of images** to **1**.

1. Choose **Run** to run inference on the model. The generated image appears above the prompt.

# Get started with the API
<a name="getting-started-api"></a>

This section describes how to set up your environment to make Amazon Bedrock requests through the AWS API. AWS offers the following tools to streamline your experience:
+ AWS Command Line Interface (AWS CLI)
+ AWS SDKs
+ Amazon SageMaker AI notebooks

To get started with the API, you need credentials to grant programmatic access. If the following sections pertain to you, expand them and follow the instructions. Otherwise, proceed through the remaining sections.

## I'm new to AWS
<a name="gs-api-new-to-aws"></a>

If you do not have an AWS account, complete the following steps to create one.

**To sign up for an AWS account**

1. Open [https://portal.aws.amazon.com/billing/signup](https://portal.aws.amazon.com/billing/signup).

1. Follow the online instructions.

   Part of the sign-up procedure involves receiving a phone call or text message and entering a verification code on the phone keypad.

   When you sign up for an AWS account, an *AWS account root user* is created. The root user has access to all AWS services and resources in the account. As a security best practice, assign administrative access to a user, and use only the root user to perform [tasks that require root user access](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks).

AWS sends you a confirmation email after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to [https://aws.amazon.com/](https://aws.amazon.com/) and choosing **My Account**.

**Secure your AWS account root user**

1.  Sign in to the [AWS Management Console](https://console.aws.amazon.com/) as the account owner by choosing **Root user** and entering your AWS account email address. On the next page, enter your password.

   For help signing in by using root user, see [Signing in as the root user](https://docs.aws.amazon.com/signin/latest/userguide/console-sign-in-tutorials.html#introduction-to-root-user-sign-in-tutorial) in the *AWS Sign-In User Guide*.

1. Turn on multi-factor authentication (MFA) for your root user.

   For instructions, see [Enable a virtual MFA device for your AWS account root user (console)](https://docs.aws.amazon.com/IAM/latest/UserGuide/enable-virt-mfa-for-root.html) in the *IAM User Guide*.

## I need to install the AWS CLI or an AWS SDK
<a name="gs-api-cli-sdk-install"></a>

To install the AWS CLI, follow the steps at [Install or update to the latest version of the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).

To install an AWS SDK, select the tab that corresponds to the programming language that you want to use at [Tools to Build on AWS](https://aws.amazon.com/developer/tools/). AWS software development kits (SDKs) are available for many popular programming languages. Each SDK provides an API, code examples, and documentation that make it easier for developers to build applications in their preferred language. SDKs automatically perform useful tasks for you, such as:
+ Cryptographically sign your service requests
+ Retry requests
+ Handle error responses

## Get credentials to grant programmatic access
<a name="gs-grant-program-access"></a>

Users need programmatic access if they want to interact with AWS outside of the AWS Management Console. AWS provides multiple options, depending on your security concerns.

**Note**  
For a step-by-step guide to generate an API key that you can use to quickly access the Amazon Bedrock API, see [Get started with Amazon Bedrock API keys: Generate a 30-day key and make your first API call](getting-started-api-keys.md).  
For greater security requirements, continue through this section.

The way to grant programmatic access depends on the type of user that's accessing AWS.

To grant users programmatic access, choose one of the following options.


****  

| Which principal needs programmatic access? | To | By | 
| --- | --- | --- | 
| IAM users | Limit the duration of long-term credentials to sign programmatic requests to the AWS CLI, AWS SDKs, or AWS APIs. |  Following the instructions for the interface that you want to use. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/bedrock/latest/userguide/getting-started-api.html)  | 
| IAM roles | Use temporary credentials to sign programmatic requests to the AWS CLI, AWS SDKs, or AWS APIs. | Following the instructions in [Using temporary credentials with AWS resources](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html) in the IAM User Guide. | 
|  Workforce identity (Users managed in IAM Identity Center)  | Use temporary credentials to sign programmatic requests to the AWS CLI, AWS SDKs, or AWS APIs. |  Following the instructions for the interface that you want to use. [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/bedrock/latest/userguide/getting-started-api.html)  | 

## How to configure access keys for an IAM user
<a name="create-user-time-bound"></a>

If you decide to use access keys for an IAM user, AWS recommends that you set an expiration for the IAM user by including a restrictive inline policy.

**Important**  
Heed the following warnings:  
**Do NOT** use your account's root credentials to access AWS resources. These credentials provide unrestricted account access and are difficult to revoke.
**Do NOT** put literal access keys or credential information in your application files. If you do, you create a risk of accidentally exposing your credentials if, for example, you upload the project to a public repository.
**Do NOT** include files that contain credentials in your project area.
Manage your access keys securely. Do not provide your access keys to unauthorized parties, even to help [find your account identifiers](https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html). By doing this, you might give someone permanent access to your account.
Be aware that any credentials stored in the shared AWS credentials file are stored in plaintext.

For more details, see [Best practices for managing AWS access keys](https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html) in the AWS General Reference.

**Create an IAM user**

1. On the AWS Management Console Home page, select the IAM service or navigate to the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).

1. In the navigation pane, select **Users** and then select **Create user**.

1. Follow the guidance in the IAM console to set up a programmatic user (without access to the AWS Management Console) and without permissions.

**Restrict user access to a limited time window**

Any IAM user access keys that you create are long-term credentials. To ensure that these credentials expire in case they are mishandled, you can make these credentials time-bound by creating an inline policy that specifies a date after which the keys will no longer be valid.

1. Open the IAM user that you just created. In the **Permissions** tab, choose **Add permissions** and then choose **Create inline policy**.

1. In the JSON editor, specify the following permissions. To use this policy, replace the value for `aws:CurrentTime` timestamp value in the example policy with your own end date.
**Note**  
IAM recommends that you limit your access keys to 12 hours.

------
#### [ JSON ]

****  

   ```
   {
     "Version":"2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Deny",
         "Action": "*",
         "Resource": "*",
         "Condition": {
           "DateGreaterThan": {
             "aws:CurrentTime": "2024-01-01T00:00:000"
           }
         }
       }
     ]
   }
   ```

------

**Create an access key**

1. On the **User details** page, select the **Security credentials** tab. In the **Access keys** section, choose **Create access key**.

1. Indicate that you plan to use these access keys as **Other** and choose **Create access key**.

1. On the **Retrieve access key** page, choose **Show** to reveal the value of your user's secret access key. You can copy the credentials or download a .csv file.

**Important**  
When you no longer need this IAM user, we recommend that you remove it and align with the [AWS security best practice](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#lock-away-credentials), we recommend that you require your human users to use temporary credentials through [AWS IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/getting-started.html) when accessing AWS.

## Attach Amazon Bedrock permissions to a user or role
<a name="gs-api-br-permissions"></a>

After setting up credentials for programmatic access, you need to configure permissions for a user or IAM role to have access a set of Amazon Bedrock-related actions. To set up these permissions, do the following:

1. On the AWS Management Console Home page, select the IAM service or navigate to the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/).

1. Select **Users** or **Roles** and then select your user or role.

1. In the **Permissions** tab, choose **Add permissions** and then choose **Add AWS managed policy**. Choose the [AmazonBedrockFullAccess]() AWS managed policy.

1. To allow the user or role to subscribe to models, choose **Create inline policy** and then specify the following permissions in the JSON editor:

------
#### [ JSON ]

****  

   ```
   {
     "Version":"2012-10-17",		 	 	 
     "Statement": [
         {
             "Sid": "MarketplaceBedrock",
             "Effect": "Allow",
             "Action": [
                 "aws-marketplace:ViewSubscriptions",
                 "aws-marketplace:Unsubscribe",
                 "aws-marketplace:Subscribe"
             ],
             "Resource": "*"
         }
     ]
   }
   ```

------

## Try making API calls to Amazon Bedrock
<a name="gs-try-bedrock"></a>

After you've fulfilled all the prerequisites, select one of the following topics to test out making model invocation requests using Amazon Bedrock models:

**Topics**
+ [Get credentials to grant programmatic access](#gs-grant-program-access)
+ [Attach Amazon Bedrock permissions to a user or role](#gs-api-br-permissions)
+ [Try making API calls to Amazon Bedrock](#gs-try-bedrock)
+ [Get started with Amazon Bedrock API keys: Generate a 30-day key and make your first API call](getting-started-api-keys.md)
+ [Run example Amazon Bedrock API requests with the AWS Command Line Interface](getting-started-api-ex-cli.md)
+ [Run example Amazon Bedrock API requests through the AWS SDK for Python (Boto3)](getting-started-api-ex-python.md)
+ [Run example Amazon Bedrock API requests using an Amazon SageMaker AI notebook](getting-started-api-ex-sm.md)

# Get started with Amazon Bedrock API keys: Generate a 30-day key and make your first API call
<a name="getting-started-api-keys"></a>

This tutorial walks you through creating a long-term Amazon Bedrock API key that expires in 30 days and using it to make a simple [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) API call using Python. This is the fastest way to start experimenting with Amazon Bedrock without setting up complex AWS credentials.

**Warning**  
Long-term API keys are recommended only for exploration and development of Amazon Bedrock. For production applications, use [alternatives to long-term access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds-programmatic-access.html#security-creds-alternatives-to-long-term-access-keys) such as IAM roles or temporary credentials.

Follow these steps to create a long-term Amazon Bedrock API key that expires in 30 days:

1. Sign in to the AWS Management Console with an IAM identity that has permissions to use the Amazon Bedrock console. Then, open the Amazon Bedrock console at [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock).

1. In the left navigation pane, select **API keys**.

1. In the **Long-term API keys** tab, choose **Generate long-term API keys**.

1. In the **API key expiration** section, select **30 days**.

1. Choose **Generate**. The key you generate provides permissions to carry out core Amazon Bedrock actions, as defined in the attached [AmazonBedrockLimitedAccess](security-iam-awsmanpol.md#security-iam-awsmanpol-AmazonBedrockLimitedAccess) policy.

1. Copy the generated API key and store it securely. You'll need this key for the next step.
**Important**  
The API key is only displayed once. Make sure to copy and save it before closing the dialog. Remember that your API key will expire in 30 days. You can generate a new one by following the same steps, or consider transitioning to more secure authentication methods for ongoing use.

1. Set the API key as an environment variable by replacing *\$1\$1api-key\$1* with your generated API key value and use it to generate a response in your method of choice:

------
#### [ Python ]

   ```
   import boto3
   import os
   
   # Set the API key as an environment variable
   os.environ['AWS_BEARER_TOKEN_BEDROCK'] = "${api-key}"
   
   # Create the Bedrock client
   client = boto3.client(
       service_name="bedrock-runtime",
       region_name="us-east-1"
   )
   
   # Define the model and message
   model_id = "us.anthropic.claude-3-5-haiku-20241022-v1:0"
   messages = [{"role": "user", "content": [{"text": "Hello! Can you tell me about Amazon Bedrock?"}]}]
   
   # Make the API call
   response = client.converse(
       modelId=model_id,
       messages=messages,
   )
   
   # Print the response
   print(response['output']['message']['content'][0]['text'])
   ```

------
#### [ HTTP client using Python ]

   ```
   import requests
   
   url = "https://bedrock-runtime.us-east-1.amazonaws.com/model/us.anthropic.claude-3-5-haiku-20241022-v1:0/converse"
   
   payload = {
       "messages": [
           {
               "role": "user",
               "content": [{"text": "Hello"}]
           }
       ]
   }
   
   headers = {
       "Content-Type": "application/json",
       "Authorization": "Bearer ${api-key}"
   }
   
   response = requests.request("POST", url, json=payload, headers=headers)
   
   print(response.text)
   ```

------
#### [ HTTP request using cURL ]

   ```
   curl -X POST "https://bedrock-runtime.us-east-1.amazonaws.com/model/us.anthropic.claude-3-5-haiku-20241022-v1:0/converse" \
     -H "Content-Type: application/json" \
     -H "Authorization: Bearer ${api-key}" \
     -d '{
       "messages": [
           {
               "role": "user",
               "content": [{"text": "Hello"}]
           }
       ]
     }'
   ```

------

Congratulations\$1 You've successfully generated an Amazon Bedrock API key and made your first API call to the Amazon Bedrock service. After exploring some more Amazon Bedrock actions, you should transition to more secure methods of authentication such as short-term Amazon Bedrock API keys or AWS-wide temporary credentials. Refer to the following resources to learn more:
+ **Explore different models** – Learn about other foundation models available in Amazon Bedrock at [Using models with Bedrock](foundation-models-reference.md) and change the `model_id` in your code to try them out.
+ **Learn about model inference** – Learn about generating responses with model inference by reading about concepts and the options available in Amazon Bedrock at [Submit prompts and generate responses with model inference](inference.md).
+ **Plan for production with more secure authentication methods** – Read about Amazon Bedrock API keys in greater detail in the Build chapter and how to create more secure, short-term Amazon Bedrock API keys. When you're ready to build production applications, you should also review [alternatives to long-term access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds-programmatic-access.html#security-creds-alternatives-to-long-term-access-keys) for more secure options that also allow access to other AWS services.

# Run example Amazon Bedrock API requests with the AWS Command Line Interface
<a name="getting-started-api-ex-cli"></a>

This section guides you through trying out some common operations in Amazon Bedrock using the AWS Command Line Interface to test that your permissions and authentication are set up properly. Before you run the following examples, you should check that you have fulfilled the following prerequisites:

**Prerequisites**
+ You have an AWS account and a user or role with authentication set up and the necessary permissions for Amazon Bedrock. Otherwise, follow the steps at [Get started with the API](getting-started-api.md).
+ You've installed and set up authentication for the AWS CLI. To install the AWS CLI, follow the steps at [Install or update to the latest version of the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). Verify that you've set up your credentials to use the CLI by following the steps at [Get credentials to grant programmatic access](getting-started-api.md#gs-grant-program-access).

Test that your permissions are set up properly for Amazon Bedrock, using a user or role that you set up with the proper permissions.

**Topics**
+ [List the foundation models that Amazon Bedrock has to offer](#getting-started-api-ex-cli-listfm)
+ [Submit a text prompt to a model and generate a text response with InvokeModel](#getting-started-api-ex-cli-invoke-text)
+ [Submit a text prompt to a model and generate a text response with Converse](#getting-started-api-ex-cli-converse)

## List the foundation models that Amazon Bedrock has to offer
<a name="getting-started-api-ex-cli-listfm"></a>

The following example runs the [ListFoundationModels](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html) operation using the AWS CLI. `ListFoundationModels` lists the foundation models (FMs) that are available in Amazon Bedrock in your Region. In a terminal, run the following command:

```
aws bedrock list-foundation-models
```

If the command is successful, the response returns a list of foundation models that are available in Amazon Bedrock.

## Submit a text prompt to a model and generate a text response with InvokeModel
<a name="getting-started-api-ex-cli-invoke-text"></a>

The following example runs the [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) operation using the AWS CLI. `InvokeModel` lets you submit a prompt to generate a model response. In a terminal, run the following command:

```
aws bedrock-runtime invoke-model \
--model-id amazon.titan-text-express-v1 \
--body '{"inputText": "Describe the purpose of a \"hello world\" program in one line.", "textGenerationConfig" : {"maxTokenCount": 512, "temperature": 0.5, "topP": 0.9}}' \
--cli-binary-format raw-in-base64-out \
invoke-model-output-text.txt
```

If the command is successful, the response generated by the model is written to the `invoke-model-output-text.txt` file. The text response is returned in the `outputText` field, alongside accompanying information.

## Submit a text prompt to a model and generate a text response with Converse
<a name="getting-started-api-ex-cli-converse"></a>

The following example runs the [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) operation using the AWS CLI. `Converse` lets you submit a prompt to generate a model response. We recommend using `Converse` operation over `InvokeModel` when supported, because it unifies the inference request across Amazon Bedrock models and simplifies the management of multi-turn conversations. In a terminal, run the following command:

```
aws bedrock-runtime converse \
--model-id amazon.titan-text-express-v1 \
--messages '[{"role": "user", "content": [{"text": "Describe the purpose of a \"hello world\" program in one line."}]}]' \
--inference-config '{"maxTokens": 512, "temperature": 0.5, "topP": 0.9}'
```

If the command is successful, the response generated by the model is returned in the `text` field, alongside accompanying information.

# Run example Amazon Bedrock API requests through the AWS SDK for Python (Boto3)
<a name="getting-started-api-ex-python"></a>

This section guides you through trying out some common operations in Amazon Bedrock with the AWS Python to test that your permissions and authentication are set up properly. Before you run the following examples, you should check that you have fulfilled the following prerequisites:

**Prerequisites**
+ You have an AWS account and a user or role with authentication set up and the necessary permissions for Amazon Bedrock. Otherwise, follow the steps at [Get started with the API](getting-started-api.md).
+ You've installed and set up authentication for the AWS SDK for Python (Boto3). To install Boto3, follow the steps at [Quickstart](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html) in the Boto3 documentation. Verify that you've set up your credentials to use Boto3 by following the steps at [Get credentials to grant programmatic access](getting-started-api.md#gs-grant-program-access).

Test that your permissions are set up properly for Amazon Bedrock, using a user or role that you set up with the proper permissions. 

The Amazon Bedrock documentation also includes code examples for other programming languages. For more information, see [Code examples for Amazon Bedrock using AWS SDKs](service_code_examples.md).

**Topics**
+ [List the foundation models that Amazon Bedrock has to offer](#getting-started-api-ex-python-listfm)
+ [Submit a text prompt to a model and generate a text response with InvokeModel](#getting-started-api-ex-python-invoke-text)
+ [Submit a text prompt to a model and generate a text response with Converse](#getting-started-api-ex-python-converse)

## List the foundation models that Amazon Bedrock has to offer
<a name="getting-started-api-ex-python-listfm"></a>

The following example runs the [ListFoundationModels](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html) operation using an Amazon Bedrock client. `ListFoundationModels` lists the foundation models (FMs) that are available in Amazon Bedrock in your Region. Run the following SDK for Python script to create an Amazon Bedrock client and test the [ListFoundationModels](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html) operation:

```
"""
Lists the available Amazon Bedrock models in an &AWS-Region;.
"""
import logging
import json
import boto3


from botocore.exceptions import ClientError


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def list_foundation_models(bedrock_client):
    """
    Gets a list of available Amazon Bedrock foundation models.

    :return: The list of available bedrock foundation models.
    """

    try:
        response = bedrock_client.list_foundation_models()
        models = response["modelSummaries"]
        logger.info("Got %s foundation models.", len(models))
        return models

    except ClientError:
        logger.error("Couldn't list foundation models.")
        raise


def main():
    """Entry point for the example. Change aws_region to the &AWS-Region;
    that you want to use."""
   
    aws_region = "us-east-1"

    bedrock_client = boto3.client(service_name="bedrock", region_name=aws_region)
    
    fm_models = list_foundation_models(bedrock_client)
    for model in fm_models:
        print(f"Model: {model["modelName"]}")
        print(json.dumps(model, indent=2))
        print("---------------------------\n")
    
    logger.info("Done.")

if __name__ == "__main__":
    main()
```

If the script is successful, the response returns a list of foundation models that are available in Amazon Bedrock.

## Submit a text prompt to a model and generate a text response with InvokeModel
<a name="getting-started-api-ex-python-invoke-text"></a>

The following example runs the [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) operation using an Amazon Bedrock client. `InvokeModel` lets you submit a prompt to generate a model response. Run the following SDK for Python script to create an Amazon Bedrock runtime client and generate a text response with the `` operation:

```
# Use the native inference API to send a text message to Amazon Nova Micro.

import boto3
import json

from botocore.exceptions import ClientError

# Create an Amazon Bedrock Runtime client.
brt = boto3.client("bedrock-runtime")

# Set the model ID, e.g., Amazon Nova Micro.
model_id = "amazon.nova-micro-v1:0"

# Define the prompt for the model.
prompt = "Describe the purpose of a 'hello world' program in one line."

# Format the request payload using the model's native structure.
native_request = {
    "messages": [
        {
            "role": "user",
            "content": [{"text": prompt}]
        }
    ],
    "inferenceConfig": {
        "maxTokens": 512,
        "temperature": 0.5,
        "topP": 0.9
    },
}

# Convert the native request to JSON.
request = json.dumps(native_request)

try:
    # Invoke the model with the request.
    response = brt.invoke_model(modelId=model_id, body=request)

except (ClientError, Exception) as e:
    print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}")
    exit(1)

# Decode the response body.
model_response = json.loads(response["body"].read())

# Extract and print the response text.
response_text = model_response["output"]["message"]["content"][0]["text"]
print(response_text)
```

If the command is successful, the response returns the text generated by the model in response to the prompt.

## Submit a text prompt to a model and generate a text response with Converse
<a name="getting-started-api-ex-python-converse"></a>

The following example runs the [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) operation using an Amazon Bedrock client. We recommend using `Converse` operation over `InvokeModel` when supported, because it unifies the inference request across Amazon Bedrock models and simplifies the management of multi-turn conversations. Run the following SDK for Python script to create an Amazon Bedrock runtime client and generate a text response with the `Converse` operation:

```
# Use the Conversation API to send a text message to Amazon Nova Micro.

import boto3
from botocore.exceptions import ClientError

# Create an Amazon Bedrock Runtime client.
brt = boto3.client("bedrock-runtime")

# Set the model ID, e.g., Amazon Nova Micro.
model_id = "amazon.nova-micro-v1:0"

# Start a conversation with the user message.
user_message = "Describe the purpose of a 'hello world' program in one line."
conversation = [
    {
        "role": "user",
        "content": [{"text": user_message}],
    }
]

try:
    # Send the message to the model, using a basic inference configuration.
    response = brt.converse(
        modelId=model_id,
        messages=conversation,
        inferenceConfig={"maxTokens": 512, "temperature": 0.5, "topP": 0.9},
    )

    # Extract and print the response text.
    response_text = response["output"]["message"]["content"][0]["text"]
    print(response_text)

except (ClientError, Exception) as e:
    print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}")
    exit(1)
```

If the command is successful, the response returns the text generated by the model in response to the prompt.

# Run example Amazon Bedrock API requests using an Amazon SageMaker AI notebook
<a name="getting-started-api-ex-sm"></a>

This section guides you through trying out some common operations in Amazon Bedrock with an Amazon SageMaker AI notebook to test that your Amazon Bedrock role permissions are set up properly. Before you run the following examples, you should check that you have fulfilled the following prerequisites:

**Prerequisites**
+ You have an AWS account and have permissions to access a role with the necessary permissions for Amazon Bedrock. Otherwise, follow the steps at [Quickstart](getting-started.md).
+ Carry out the following steps to set up IAM permissions for SageMaker AI and create a notebook:

  1. Modify the [trust policy](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#term_trust-policy) of the Amazon Bedrock role that you set up in [Quickstart](getting-started.md) through the [console](https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-managingrole-editing-console.html#roles-managingrole_edit-trust-policy), [CLI](https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-managingrole-editing-cli.html#roles-managingrole_edit-trust-policy-cli), or [API](https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-managingrole-editing-api.html#roles-managingrole_edit-trust-policy-api). Attach the following trust policy to the role to allow both the Amazon Bedrock and SageMaker AI services to assume the Amazon Bedrock role:

------
#### [ JSON ]

****  

     ```
     {
         "Version":"2012-10-17",		 	 	 
         "Statement": [
             {
                 "Sid": "BedrockTrust",
                 "Effect": "Allow",
                 "Principal": {
                     "Service": "bedrock.amazonaws.com"
                 },
                 "Action": "sts:AssumeRole"
             },
             {
                 "Sid": "SagemakerTrust",
                 "Effect": "Allow",
                 "Principal": {
                     "Service": "sagemaker.amazonaws.com"
                 },
                 "Action": "sts:AssumeRole"
             }
         ]
     }
     ```

------

  1. Sign into the Amazon Bedrock role whose trust policy you just modified.

  1. Follow the steps at [Create an Amazon SageMaker AI Notebook Instance for the tutorial](https://docs.aws.amazon.com/sagemaker/latest/dg/gs-setup-working-env.html) and specify the ARN of the Amazon Bedrock role that you created to create an SageMaker AI notebook instance.

  1. When the **Status** of the notebook instance is **InService**, choose the instance and then choose **Open JupyterLab**.

After you open up your SageMaker AI notebook, you can try out the following examples:

**Topics**
+ [List the foundation models that Amazon Bedrock has to offer](#getting-started-api-ex-sm-listfm)
+ [Submit a text prompt to a model and generate a response](#getting-started-api-ex-sm-converse)

## List the foundation models that Amazon Bedrock has to offer
<a name="getting-started-api-ex-sm-listfm"></a>

The following example runs the [ListFoundationModels](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html) operation using an Amazon Bedrock client. `ListFoundationModels` lists the foundation models (FMs) that are available in Amazon Bedrock in your Region. Run the following SDK for Python script to create an Amazon Bedrock client and test the [ListFoundationModels](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_ListFoundationModels.html) operation:

```
"""
Lists the available Amazon Bedrock models in an &AWS-Region;.
"""
import logging
import json
import boto3


from botocore.exceptions import ClientError


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def list_foundation_models(bedrock_client):
    """
    Gets a list of available Amazon Bedrock foundation models.

    :return: The list of available bedrock foundation models.
    """

    try:
        response = bedrock_client.list_foundation_models()
        models = response["modelSummaries"]
        logger.info("Got %s foundation models.", len(models))
        return models

    except ClientError:
        logger.error("Couldn't list foundation models.")
        raise


def main():
    """Entry point for the example. Change aws_region to the &AWS-Region;
    that you want to use."""
   
    aws_region = "us-east-1"

    bedrock_client = boto3.client(service_name="bedrock", region_name=aws_region)
    
    fm_models = list_foundation_models(bedrock_client)
    for model in fm_models:
        print(f"Model: {model["modelName"]}")
        print(json.dumps(model, indent=2))
        print("---------------------------\n")
    
    logger.info("Done.")

if __name__ == "__main__":
    main()
```

If the script is successful, the response returns a list of foundation models that are available in Amazon Bedrock.

## Submit a text prompt to a model and generate a response
<a name="getting-started-api-ex-sm-converse"></a>

The following example runs the [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) operation using an Amazon Bedrock client. `Converse` lets you submit a prompt to generate a model response. Run the following SDK for Python script to create an Amazon Bedrock runtime client and test the [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) operation:

```
# Use the Conversation API to send a text message to Amazon Nova Micro.

import boto3
from botocore.exceptions import ClientError

# Create an Amazon Bedrock Runtime client.
brt = boto3.client("bedrock-runtime")

# Set the model ID, e.g., Amazon Nova Micro.
model_id = "amazon.nova-micro-v1:0"

# Start a conversation with the user message.
user_message = "Describe the purpose of a 'hello world' program in one line."
conversation = [
    {
        "role": "user",
        "content": [{"text": user_message}],
    }
]

try:
    # Send the message to the model, using a basic inference configuration.
    response = brt.converse(
        modelId=model_id,
        messages=conversation,
        inferenceConfig={"maxTokens": 512, "temperature": 0.5, "topP": 0.9},
    )

    # Extract and print the response text.
    response_text = response["output"]["message"]["content"][0]["text"]
    print(response_text)

except (ClientError, Exception) as e:
    print(f"ERROR: Can't invoke '{model_id}'. Reason: {e}")
    exit(1)
```

If the command is successful, the response returns the text generated by the model in response to the prompt.

# Tutorial: Create a flow that processes mortgage applications
<a name="getting-started-mortgage-flow"></a>

To get familiar with Amazon Bedrock resources and their capabilities, we'll use an CloudFormation template to set up a [flow](flows.md) that automates a mortgage application process processes by combining various Amazon Bedrock and other AWS resources.

**Note**  
For this tutorial, we will use the *us-east-1* Region. You can use any Region that supports Agents, Flows, Guardrails, Knowledge bases, and Prompt management. For a table of feature support by Region, see [Feature support by AWS Region in Amazon Bedrock](features-regions.md). Make sure that you have permissions to create Amazon S3, Amazon Bedrock, Lambda, and DynamoDB resources in the Region that you use.

This flow isn't meant for deployment purposes, but rather to use as a tutorial to understand Amazon Bedrock resources. The following image is the visual representation of the flow in the AWS Management Console:

![\[Mortgage processing flow\]](http://docs.aws.amazon.com/bedrock/latest/userguide/images/cloudformation/mortgage-processing-flow.png)


The flow combines an Amazon Bedrock [agent](agents.md), [prompts](prompt-management.md), and a [Lambda function](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) to create a mortgage processing flow that intakes customer financial information and processes whether the customer qualifies for a loan. An Amazon Bedrock [knowledge base](knowledge-base.md) and [guardrail](guardrails.md) are also attached to the flow's agent to augment responses and to provide safeguards. For more detailed information about the components of the flow, see [Details about the mortgage processing flow](getting-started-mortgage-flow-details.md).

**Topics**
+ [Prerequisites](#getting-started-mortgage-flow-prereqs)
+ [Create the mortgage processing flow using CloudFormation](#getting-started-mortgage-flow-create)
+ [Test the mortgage processing flow](#getting-started-mortgage-flow-test)
+ [Clean up: deleting resources](#getting-started-mortgage-flow-delete)
+ [CloudFormation templates](getting-started-mortgage-flow-template.md)
+ [Details about the mortgage processing flow](getting-started-mortgage-flow-details.md)

## Prerequisites
<a name="getting-started-mortgage-flow-prereqs"></a>

To create this flow, you'll download a .zip file and follow instructions to run a script that will set up your resources and template for you.

**Important**  
You'll be billed for the Amazon resources that you create until you delete them.

Then, complete the following prerequisites:

1. Download the [cloudformation-mortgage-flow-setup.zip](samples/cloudformation-mortgage-flow-setup.zip) file.

1. Unzip the file. You can learn more about the contents at [CloudFormation templates](getting-started-mortgage-flow-template.md).

1. Request access to Amazon Bedrock foundation models by doing the following:

   1. Sign in to the AWS Management Console with an IAM identity that has permissions to use the Amazon Bedrock console. Then, open the Amazon Bedrock console at [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock).

   1. Make sure that you're in the **US East (N. Virginia)** Region by checking your Region in the upper-right corner. If you're not, switch Regions.

   1. Select **Model access** at the bottom of the left navigation pane.

   1. Choose **Modify model access**.

   1. Do one of the following:
      + To request access to all models, choose **Enable all models**. On the page you're taken to, the checkboxes next to all the models will be filled.
      + To request access to specific models, choose **Enable specific models**. On the page you're taken to, you have the following options:
        + To request access to all models by a provider, select the checkbox next to the provider name.
        + To request access to one model, select the checkbox next to the model name.

   1. For the purposes of the following tutorial, you should minimally request access to the **Titan Embeddings G1 - Text** and **Claude 3 Haiku** models. Then choose **Next**.

   1. Review the models that you're requesting access to and the **Terms**. When you're ready, choose **Submit** to request access.

## Create the mortgage processing flow using CloudFormation
<a name="getting-started-mortgage-flow-create"></a>

To create the mortgage processing flow and its associated resources, we'll create a CloudFormation template and use it to create a stack containing Amazon Bedrock resources.

**Important**  
You'll be billed for the Amazon resources that you create until you delete them.

### Create the resources and CloudFormation template file
<a name="getting-started-mortgage-flow-file"></a>

First, use the script from the .zip file to upload the resources to an S3 bucket and to create the CloudFormation templates.

1. In a terminal, run the following command to copy the resources into an Amazon S3 bucket and populate the `main-stack.yaml` and `main-stack.json` files with the S3 bucket name as the default value for the bucket name parameter.

   ```
   bash deploy.sh
   ```
**Note**  
The usage of the script is `bash deploy.sh <region> <bucket-name>`, where *<region>* and *<bucket-name>* are optional arguments. If you don't provide them, the following default values will be used:  
*<region>* – The default AWS Region specified in your AWS credentials setup.
*<bucket-name>* – The bucket will be named *mortgage-flow-deployment-<AccountId>-<Region>*, where *<AccountId>* is your AWS account ID and *<Region>* matches the value you provide or the default AWS Region specified in your AWS credentials setup.

1. Confirm the prompts. After the deployment is complete, you should have a complete `main-stack.yaml` and `main-stack.json` template for the next step.

**Note**  
If the script fails, you can manually prepare the resources by doing the following:  
Upload the *contents* (don't include the folder itself) of the unzipped `cloudformation-mortgage-flow-setup` folder to an S3 bucket in US East (N. Virginia) in the Amazon S3 console at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/).
Find the `templates/json/main-stack-tmp.yaml` or `templates/json/main-stack-tmp.json` file and do the following:  
Change the `Default` value of the `Q01pS3BucketName` parameter from *MortgageFlowBucket* to your S3 bucket name.
Remove `-tmp` from the file name, such that it becomes `templates/json/main-stack.yaml` or `templates/json/main-stack.json`.

### Create the stack by using the CloudFormation console
<a name="getting-started-mortgage-flow-stack"></a>

Next, use the template you've saved to provision a CloudFormation stack.

1. Open the CloudFormation console at [https://console.aws.amazon.com/cloudformation](https://console.aws.amazon.com/cloudformation/). Make sure that you're in the **US East (N. Virginia)** Region by checking your Region in the upper-right corner. If you're not, switch Regions.

1. On the **Stacks** page, from the **Create stack** menu, choose **With new resources (standard)**.

1. Specify the template:

   1. Under **Prerequisite**, choose **Choose an existing template**.

   1. Under **Specify template**, choose **Upload a template file**.

   1. Choose **Choose file**, navigate to the `main-stack.yaml` or the `main-stack.json` template, and select it.

   1. Choose **Next**.

1. Specify the stack details:

   1. In the **Stack name** field, enter a name for the stack.

   1. In the **Parameters** field, leave the default values.
**Note**  
The `Q01pS3BucketName` value should match the name of the S3 bucket to which you uploaded the resources for this template. The remaining arguments are related to the configurations of the knowledge base--if you modify any of them, make sure that the configurations are compatible with each other. For more information, see [Prerequisites for using a vector store you created for a knowledge base](knowledge-base-setup.md).

   1. Choose **Next**.

1. Configure the stack options:

   1. Under **Stack failure options**, choose **Delete all newly created resources**.
**Note**  
Choosing this option prevents you from possibly being billed for resources whose deletion policy specifies they be retained even if the stack creation fails. For more information, see [`DeletionPolicy` attribute](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html) in the *CloudFormation User Guide*.

   1. Under **Capabilities**, check the box to acknowledge that CloudFormation might create IAM resources in your account.

   1. Choose **Next**.

1. Review the stack details and choose **Submit**. CloudFormation creates the stack. The creation will take several minutes. After the stack creation is complete, you can use the **Resources** tab on the stack detail page to view the resources that where provisioned in your account.

1. After the stack creation completes, do the following to sync the data source for the knowledge base so that the knowledge base can be queried:

   1. Sign in to the AWS Management Console with an IAM identity that has permissions to use the Amazon Bedrock console. Then, open the Amazon Bedrock console at [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock).

   1. From the left navigation pane, choose **Knowledge Bases** and then select the knowledge base that was created, named `AWSDocsTutorial-MortgageKB`.

   1. In the **Data source** section, select the checkbox next to the data source that was created, named `AWSDocsTutorial-MortgageKB-DS`.

   1. Choose **Sync**. After syncing completes, you can test the flow.

## Test the mortgage processing flow
<a name="getting-started-mortgage-flow-test"></a>

Once the mortgage processing flow has been created, you can use the Amazon Bedrock console to examine, test, and modify the flow. You can also examine, test, and modify the individual resources in the flow.

**To test the flow**

1. Sign in to the AWS Management Console with an IAM identity that has permissions to use the Amazon Bedrock console. Then, open the Amazon Bedrock console at [https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock).

1. From the left navigation pane, choose **Flows**. Make sure that you're in the **US East (N. Virginia)** Region by checking your Region in the upper-right corner. If you're not, switch Regions.

1. In the **Flows** section, select the flow that was created from the CloudFormation template. It should be `AWSDocsTutorial-MortgageFlow`.

1. Choose **Edit in flow builder**. You can drag individual nodes in the flow to modify the visual representation of the flow.

1. In the **Test flow** pane, enter the following in the text field and then select **Run**.

   ```
   {
       "income": 80000, 
       "totalDebt": 5000, 
       "loanTerm": 30, 
       "loanAmount": 600000, 
       "creditScore": 750, 
       "mlsId": "MLS-5678"
   }
   ```

   Because the loan amount is greater than the calculated maximum affordable loan, the **incomeDebt** prompt is triggered and the flow generates a rejection letter. You can choose **Show trace** to see the nodes that were run in the flow.

1. Again, in the **Test flow** pane, enter the following in the text field and then select **Run**.

   ```
   {
       "income": 120000, 
       "totalDebt": 5000, 
       "loanTerm": 30, 
       "loanAmount": 200000, 
       "creditScore": 650, 
       "mlsId": "MLS-3456"
   }
   ```

   Because the loan amount is less than the calculated maximum affordable loan, the **processApplication** prompt is triggered and sent to the **mortgageProcessingAgent**, which looks up the attached knowledge base and generates a response that assesses, based on the input values, whether the customer qualifies for a loan.

1. (Optional) Try running the flow by using different values for the fields in the JSON object. The `mlsId` values correspond to properties listed on the Multiple Listing Service. You can find valid `mlsId` values by doing the following:

   1. Sign in to the AWS Management Console and open the DynamoDB console at [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/).

   1. In the left navigation pane, select **Tables**.

   1. Select the table that says **AWSDocsTutorial-PropertyListing**.

   1. Choose **Explore table items**.

   1. You can use any of the values in the **mls\$1id** column in the flow input.

You can also navigate to the **Agents**, **Knowledge Bases**, **Guardrails**, and **Prompt management** pages in the AWS Management Console to examine each Amazon Bedrock resource used in the flow, independently. To learn more about the flow and understand the components in more detail, see [Details about the mortgage processing flow](getting-started-mortgage-flow-details.md).

## Clean up: deleting resources
<a name="getting-started-mortgage-flow-delete"></a>

After you explore the resources and have a better understanding of the capabilities of different Amazon Bedrock resources, we'll delete the stack and the resources it contains.

**Important**  
You'll be billed for the Amazon resources that you create until you delete them.

1. Open the [https://console.aws.amazon.com/cloudformation](https://console.aws.amazon.com/cloudformation/).

1. From the left navigation pain, choose **Stacks**.

1. Choose the stack that you created from the template. Then choose **Delete**, then confirm **Delete**.

   CloudFormation initiates deletion of the main stack, all its nested stacks, and all resources included in the stacks.

# CloudFormation templates
<a name="getting-started-mortgage-flow-template"></a>

The `cloudformation-mortgage-flow-setup.zip` file that you download contains the following files:
+ `deploy.sh` – A shell script that deploys your resources and prepares the main CloudFormation template that you'll use.
+ `artifacts` – A folder that contains .zip files with functions for the agent and knowledge base templates:
  + Lambda functions for the agent's action groups
    + `agent_loan_calculator.zip`
    + `mls_lookup.zip`
    + `loader_deployment_package.zip`
  + Functions for setting up the knowledge base
    + `custom-resource-lambda.zip`
    + `opensearchpy-layer.zip`
    + `provider-event-handler.zip`
+ `api-schema` – A folder that contains API schemas for action groups.
+ `knowledge-base-data-source` – A folder that contains the PDF for [Fannie Mae's Selling Guide](https://selling-guide.fanniemae.com/).
+ `templates` – A folder that contains the templates for the resources in this flow, both in JSON and YAML format:
  + `main-stack-tmp` – The main template that deploys the remaining templates as nested stacks. This file is turned into `main-stack` after the deployment script is run.
  + `guardrails-template` – The template for the guardrail to be associated with the agent.
  + `prompts-template` – The template for the prompts to be used in flow.
  + `kb-role-template` – The template for the knowledge base role, to be used both by the OpenSearch template and by the knowledge base template.
  + `oss-infra-template` – The template for the Amazon OpenSearch Serverless vector store to be used for the knowledge base.
  + `kb-infra-template` – The template for the mortgage loan knowledge base to be associated with the agent.
  + `agent-template` – The template for mortgage processing agent to be used in the flow.
  + `mortgage-flow-template` – The template for the mortgage processing flow that combines all the resources.
+ `README.md` – A README file that describes the steps for using the template.

The following topics show the CloudFormation templates used for each stack. The main stack deploys the remaining stacks as [nested stacks](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html).

**Topics**
+ [Main stack](#getting-started-mortgage-templates-main)
+ [Amazon Bedrock Guardrails stack](#getting-started-mortgage-guardrail-templates)
+ [Amazon Bedrock Prompt management stack](#getting-started-mortgage-prompts-templates)
+ [Amazon Bedrock Knowledge Bases stack](#getting-started-mortgage-kb-templates)

## Main stack
<a name="getting-started-mortgage-templates-main"></a>

The main stack defines the parameters that you can define when you upload the template. These values are passed on to each of the remaining nested stacks. The deployment script replaces *MortgageFlowBucket* for the default value of the `Q01pS3BucketName` parameter with your actual S3 bucket that contains the resources deployed by the script.

------
#### [ YAML ]

```
AWSTemplateFormatVersion: '2010-09-09'
Description: "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow"

Parameters:
  Q01pS3BucketName:
    Type: String
    Description: Provide existing S3 bucket name where data is already stored
    Default: MortgageFlowBucket
  Q02pFlowName:
    Type: String
    Description: Name for the flow
    Default: MortgageFlow
  Q03pGuardrailName:
    Type: String
    Description: Name for guardrail to attach to agent
    Default: MortgageGR
  Q04pKnowledgeBaseName:
    Type: String
    Description: Name for knowledge base to associate with agent
    Default: MortgageKB
  Q05pAgentName:
    Type: String
    Description: Name for agent to create
    Default: MortgageAgent
  Q06pKBEmbedModel:
    Type: String
    Description: Select Embedding model
    Default: amazon.titan-embed-text-v1
  Q07pKBChunkingStrategy:
    Type: String
    Description: Select Chunking strategy
    AllowedValues:
      - Default chunking
      - Fixed-size chunking
      - No chunking
    Default: Default chunking
  Q08pKBMaxTokens:
    Type: Number
    Description: Maximum number of tokens in a chunk
    Default: 300
  Q09pKBOverlapPercentage:
    Type: Number
    Description: Percent overlap in each chunk
    Default: 20
  Q10pKBVectorStore:
    Type: String
    Description: Select vector store
    AllowedValues:
    - Open-Search-Serverless
    Default: Open-Search-Serverless
  Q11pOSSCollectionName:
    Type: String
    Description: Name of the Collection
    MinLength: 1
    MaxLength: 63
    Default: mortgage-kb-collection
    AllowedPattern: ^[a-z0-9](-*[a-z0-9])*
    ConstraintDescription: Must be lowercase or numbers with a length of 1-32 characters
  Q12pOSSIndexName:
    Type: String
    Description: Index name to be created in vector store
    MinLength: 1
    MaxLength: 63
    Default: mortgage-kb-index
    AllowedPattern: ^[a-z0-9](-*[a-z0-9])*
    ConstraintDescription: Must be lowercase or numbers with a length of 1-63 characters
  # Q13pVectorFieldName:
  #   Type: String
  #   Description: Vector field name
  #   Default: bedrock-knowledge-base-default-vector
  # Q14pMetaDataFieldName:
  #   Type: String
  #   Description: Metadata field name
  #   Default: AMAZON_BEDROCK_METADATA
  # Q15pTextFieldName:
  #   Type: String
  #   Description: Text field name
  #   Default: AMAZON_BEDROCK_TEXT_CHUNK
Resources:
  KBRoleStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub https://${Q01pS3BucketName}.s3.amazonaws.com/templates/yaml/kb-role-template.yaml
      TimeoutInMinutes: 15
      Parameters:
        Q01pS3BucketName:
          Ref: Q01pS3BucketName
  OSSStack:
    Type: AWS::CloudFormation::Stack
    DependsOn: KBRoleStack
    Properties:
      TemplateURL: !Sub https://${Q01pS3BucketName}.s3.amazonaws.com/templates/yaml/oss-infra-template.yaml
      TimeoutInMinutes: 15
      Parameters:
        Q01pS3BucketName:
          Ref: Q01pS3BucketName
        Q06pKBEmbedModel:
          Ref: Q06pKBEmbedModel
        Q11pOSSCollectionName:
          Ref: Q11pOSSCollectionName
        Q12pOSSIndexName:
          Ref: Q12pOSSIndexName
        pKBRole:
          Fn::GetAtt:
          - KBRoleStack
          - Outputs.KBRole
        pKBRoleArn:
          Fn::GetAtt:
          - KBRoleStack
          - Outputs.KBRoleArn
  KBStack:
    Type: AWS::CloudFormation::Stack
    DependsOn: OSSStack
    Properties:
      TemplateURL: !Sub https://${Q01pS3BucketName}.s3.amazonaws.com/templates/yaml/kb-infra-template.yaml
      TimeoutInMinutes: 15
      Parameters:
        KnowledgeBaseName:
          Ref: Q04pKnowledgeBaseName
        Q01pS3BucketName:
          Ref: Q01pS3BucketName
        Q06pKBEmbedModel:
          Ref: Q06pKBEmbedModel
        Q07pKBChunkingStrategy:
          Ref: Q07pKBChunkingStrategy
        Q08pKBMaxTokens:
          Ref: Q08pKBMaxTokens
        Q09pKBOverlapPercentage:
          Ref: Q09pKBOverlapPercentage
        Q11pOSSCollectionName:
          Ref: Q11pOSSCollectionName
        Q12pOSSIndexName:
          Ref: Q12pOSSIndexName
        # Q13pVectorFieldName:
        #   Ref: Q13pVectorFieldName
        # Q14pMetaDataFieldName:
        #   Ref: Q14pMetaDataFieldName
        # Q15pTextFieldName:
        #   Ref: Q15pTextFieldName
        pCollectionArn:
          Fn::GetAtt:
          - OSSStack
          - Outputs.CollectionArn
        pKBRoleArn:
          Fn::GetAtt:
          - KBRoleStack
          - Outputs.KBRoleArn
        pKBRole:
          Fn::GetAtt:
          - KBRoleStack
          - Outputs.KBRole
  GRStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub https://${Q01pS3BucketName}.s3.amazonaws.com/templates/yaml/guardrails-template.yaml
      TimeoutInMinutes: 15
      Parameters:
        GuardrailName:
          Ref: Q03pGuardrailName
  AgentStack:
    Type: AWS::CloudFormation::Stack
    DependsOn: 
      - KBStack
      - GRStack
    Properties:
      TemplateURL: !Sub https://${Q01pS3BucketName}.s3.amazonaws.com/templates/yaml/agent-template.yaml
      TimeoutInMinutes: 15
      Parameters:
        Q01pS3BucketName:
          Ref: Q01pS3BucketName
        KnowledgeBaseId:
          Fn::GetAtt:
          - KBStack
          - Outputs.KBId
        GuardrailArn:
          Fn::GetAtt:
          - GRStack
          - Outputs.GuardrailArn
        GuardrailVersion:
          Fn::GetAtt:
          - GRStack
          - Outputs.GuardrailVersion
  PromptsStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: !Sub https://${Q01pS3BucketName}.s3.amazonaws.com/templates/yaml/prompts-template.yaml
      TimeoutInMinutes: 15
  FlowStack:
    Type: AWS::CloudFormation::Stack
    DependsOn: 
      - AgentStack
      - PromptsStack
    Properties:
      TemplateURL: !Sub https://${Q01pS3BucketName}.s3.amazonaws.com/templates/yaml/mortgage-flow-template.yaml
      TimeoutInMinutes: 15
      Parameters:
        FlowName:
          Ref: Q02pFlowName
        Q01pS3BucketName:
          Ref: Q01pS3BucketName
        ProcessApplicationPromptArn:
          Fn::GetAtt:
          - PromptsStack
          - Outputs.ProcessApplicationPromptArn
        RejectionPromptArn:
          Fn::GetAtt:
          - PromptsStack
          - Outputs.RejectionPromptArn
        AgentId:
          Fn::GetAtt:
          - AgentStack
          - Outputs.AgentId
```

------
#### [ JSON ]

```
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow",
  "Parameters": {
    "Q01pS3BucketName": {
      "Type": "String",
      "Description": "Provide existing S3 bucket name where data is already stored",
      "Default": "MortgageFlowBucket"
    },
    "Q02pFlowName": {
      "Type": "String",
      "Description": "Name for the flow",
      "Default": "MortgageFlow"
    },
    "Q03pGuardrailName": {
      "Type": "String",
      "Description": "Name for guardrail to attach to agent",
      "Default": "MortgageGR"
    },
    "Q04pKnowledgeBaseName": {
      "Type": "String",
      "Description": "Name for knowledge base to associate with agent",
      "Default": "MortgageKB"
    },
    "Q05pAgentName": {
      "Type": "String",
      "Description": "Name for agent to create",
      "Default": "MortgageAgent"
    },
    "Q06pKBEmbedModel": {
      "Type": "String",
      "Description": "Select Embedding model",
      "Default": "amazon.titan-embed-text-v1"
    },
    "Q07pKBChunkingStrategy": {
      "Type": "String",
      "Description": "Select Chunking strategy",
      "AllowedValues": [
        "Default chunking",
        "Fixed-size chunking",
        "No chunking"
      ],
      "Default": "Default chunking"
    },
    "Q08pKBMaxTokens": {
      "Type": "Number",
      "Description": "Maximum number of tokens in a chunk",
      "Default": 300
    },
    "Q09pKBOverlapPercentage": {
      "Type": "Number",
      "Description": "Percent overlap in each chunk",
      "Default": 20
    },
    "Q10pKBVectorStore": {
      "Type": "String",
      "Description": "Select vector store",
      "AllowedValues": [
        "Open-Search-Serverless"
      ],
      "Default": "Open-Search-Serverless"
    },
    "Q11pOSSCollectionName": {
      "Type": "String",
      "Description": "Name of the Collection",
      "MinLength": 1,
      "MaxLength": 63,
      "Default": "mortgage-kb-collection",
      "AllowedPattern": "^[a-z0-9](-*[a-z0-9])*",
      "ConstraintDescription": "Must be lowercase or numbers with a length of 1-32 characters"
    },
    "Q12pOSSIndexName": {
      "Type": "String",
      "Description": "Index name to be created in vector store",
      "MinLength": 1,
      "MaxLength": 63,
      "Default": "mortgage-kb-index",
      "AllowedPattern": "^[a-z0-9](-*[a-z0-9])*",
      "ConstraintDescription": "Must be lowercase or numbers with a length of 1-63 characters"
    }
  },
  "Resources": {
    "KBRoleStack": {
      "Type": "AWS::CloudFormation::Stack",
      "Properties": {
        "TemplateURL": {
          "Fn::Sub": "https://${Q01pS3BucketName}.s3.amazonaws.com/templates/json/kb-role-template.json"
        },
        "TimeoutInMinutes": 15,
        "Parameters": {
          "Q01pS3BucketName": {
            "Ref": "Q01pS3BucketName"
          }
        }
      }
    },
    "OSSStack": {
      "Type": "AWS::CloudFormation::Stack",
      "DependsOn": "KBRoleStack",
      "Properties": {
        "TemplateURL": {
          "Fn::Sub": "https://${Q01pS3BucketName}.s3.amazonaws.com/templates/json/oss-infra-template.json"
        },
        "TimeoutInMinutes": 15,
        "Parameters": {
          "Q01pS3BucketName": {
            "Ref": "Q01pS3BucketName"
          },
          "Q06pKBEmbedModel": {
            "Ref": "Q06pKBEmbedModel"
          },
          "Q11pOSSCollectionName": {
            "Ref": "Q11pOSSCollectionName"
          },
          "Q12pOSSIndexName": {
            "Ref": "Q12pOSSIndexName"
          },
          "pKBRole": {
            "Fn::GetAtt": [
              "KBRoleStack",
              "Outputs.KBRole"
            ]
          },
          "pKBRoleArn": {
            "Fn::GetAtt": [
              "KBRoleStack",
              "Outputs.KBRoleArn"
            ]
          }
        }
      }
    },
    "KBStack": {
      "Type": "AWS::CloudFormation::Stack",
      "DependsOn": "OSSStack",
      "Properties": {
        "TemplateURL": {
          "Fn::Sub": "https://${Q01pS3BucketName}.s3.amazonaws.com/templates/json/kb-infra-template.json"
        },
        "TimeoutInMinutes": 15,
        "Parameters": {
          "KnowledgeBaseName": {
            "Ref": "Q04pKnowledgeBaseName"
          },
          "Q01pS3BucketName": {
            "Ref": "Q01pS3BucketName"
          },
          "Q06pKBEmbedModel": {
            "Ref": "Q06pKBEmbedModel"
          },
          "Q07pKBChunkingStrategy": {
            "Ref": "Q07pKBChunkingStrategy"
          },
          "Q08pKBMaxTokens": {
            "Ref": "Q08pKBMaxTokens"
          },
          "Q09pKBOverlapPercentage": {
            "Ref": "Q09pKBOverlapPercentage"
          },
          "Q11pOSSCollectionName": {
            "Ref": "Q11pOSSCollectionName"
          },
          "Q12pOSSIndexName": {
            "Ref": "Q12pOSSIndexName"
          },
          "pCollectionArn": {
            "Fn::GetAtt": [
              "OSSStack",
              "Outputs.CollectionArn"
            ]
          },
          "pKBRoleArn": {
            "Fn::GetAtt": [
              "KBRoleStack",
              "Outputs.KBRoleArn"
            ]
          },
          "pKBRole": {
            "Fn::GetAtt": [
              "KBRoleStack",
              "Outputs.KBRole"
            ]
          }
        }
      }
    },
    "GRStack": {
      "Type": "AWS::CloudFormation::Stack",
      "Properties": {
        "TemplateURL": {
          "Fn::Sub": "https://${Q01pS3BucketName}.s3.amazonaws.com/templates/json/guardrails-template.json"
        },
        "TimeoutInMinutes": 15,
        "Parameters": {
          "GuardrailName": {
            "Ref": "Q03pGuardrailName"
          }
        }
      }
    },
    "AgentStack": {
      "Type": "AWS::CloudFormation::Stack",
      "DependsOn": [
        "KBStack",
        "GRStack"
      ],
      "Properties": {
        "TemplateURL": {
          "Fn::Sub": "https://${Q01pS3BucketName}.s3.amazonaws.com/templates/json/agent-template.json"
        },
        "TimeoutInMinutes": 15,
        "Parameters": {
          "Q01pS3BucketName": {
            "Ref": "Q01pS3BucketName"
          },
          "KnowledgeBaseId": {
            "Fn::GetAtt": [
              "KBStack",
              "Outputs.KBId"
            ]
          },
          "GuardrailArn": {
            "Fn::GetAtt": [
              "GRStack",
              "Outputs.GuardrailArn"
            ]
          },
          "GuardrailVersion": {
            "Fn::GetAtt": [
              "GRStack",
              "Outputs.GuardrailVersion"
            ]
          }
        }
      }
    },
    "PromptsStack": {
      "Type": "AWS::CloudFormation::Stack",
      "Properties": {
        "TemplateURL": {
          "Fn::Sub": "https://${Q01pS3BucketName}.s3.amazonaws.com/templates/json/prompts-template.json"
        },
        "TimeoutInMinutes": 15
      }
    },
    "FlowStack": {
      "Type": "AWS::CloudFormation::Stack",
      "DependsOn": [
        "AgentStack",
        "PromptsStack"
      ],
      "Properties": {
        "TemplateURL": {
          "Fn::Sub": "https://${Q01pS3BucketName}.s3.amazonaws.com/templates/json/mortgage-flow-template.json"
        },
        "TimeoutInMinutes": 15,
        "Parameters": {
          "FlowName": {
            "Ref": "Q02pFlowName"
          },
          "Q01pS3BucketName": {
            "Ref": "Q01pS3BucketName"
          },
          "ProcessApplicationPromptArn": {
            "Fn::GetAtt": [
              "PromptsStack",
              "Outputs.ProcessApplicationPromptArn"
            ]
          },
          "RejectionPromptArn": {
            "Fn::GetAtt": [
              "PromptsStack",
              "Outputs.RejectionPromptArn"
            ]
          },
          "AgentId": {
            "Fn::GetAtt": [
              "AgentStack",
              "Outputs.AgentId"
            ]
          }
        }
      }
    }
  }
}
```

------

## Amazon Bedrock Guardrails stack
<a name="getting-started-mortgage-guardrail-templates"></a>

This stack creates the following [guardrails](guardrails.md)-related resources:
+ AgentGuardrail ([AWS::Bedrock::Guardrail](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide                         /aws-resource-bedrock-guardrail.html)) – A guardrail that provides content filtering, topic policy, and PII protection. This guardrail will be attached to the agent in the Agent stack.
+ AgentGuardrailVersion ([AWS::Bedrock::GuardrailVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide                         /aws-resource-bedrock-guardrailversion.html)) – The version of the `AgentGuardrail` resource applied to the agent.

------
#### [ YAML ]

```
AWSTemplateFormatVersion: "2010-09-09"
Description: "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow"

Parameters:
  GuardrailName:
    Type: String
    Description: Name for guardrail
    Default: MortgageGuardrail

Resources:
  AgentGuardrail:
    Type: AWS::Bedrock::Guardrail
    Properties:
      Name: !Sub AWSDocsTutorial-${GuardrailName}
      Description: Guardrail for mortgage processing with investment advice blocking, content filtering, and PII protection
      BlockedInputMessaging: "Sorry, the model cannot answer this question."
      BlockedOutputsMessaging: "Sorry, the model cannot answer this question."
      TopicPolicyConfig:
        TopicsConfig:
          - Name: InvestmentAdvice
            Definition: "Investment advice refers to inquires, guidance or recommendations regarding the management or allocation of fund or asset with the goal of generating returns or achieving specific financial objectives"
            Examples:
              - "Is investing in the stocks better than bonds?"
              - "Should I invest in gold?"
            Type: DENY
      ContentPolicyConfig:
        FiltersConfig:
          - Type: VIOLENCE
            InputStrength: HIGH
            OutputStrength: HIGH
          - Type: PROMPT_ATTACK
            InputStrength: HIGH
            OutputStrength: NONE
          - Type: MISCONDUCT
            InputStrength: HIGH
            OutputStrength: HIGH
          - Type: HATE
            InputStrength: HIGH
            OutputStrength: HIGH
          - Type: SEXUAL
            InputStrength: HIGH
            OutputStrength: HIGH
          - Type: INSULTS
            InputStrength: HIGH
            OutputStrength: HIGH
      WordPolicyConfig:
        WordsConfig:
          - Text: "crypto currency"
          - Text: "bitcoin"
        ManagedWordListsConfig:
          - Type: PROFANITY
      SensitiveInformationPolicyConfig:
        PiiEntitiesConfig:
          - Type: EMAIL
            Action: ANONYMIZE
          - Type: CREDIT_DEBIT_CARD_NUMBER
            Action: BLOCK
      ContextualGroundingPolicyConfig:
        FiltersConfig:
          - Type: GROUNDING
            Threshold: 0.85
          - Type: RELEVANCE
            Threshold: 0.5
            
  AgentGuardrailVersion:
    Type: AWS::Bedrock::GuardrailVersion
    Properties:
      GuardrailIdentifier: !Ref AgentGuardrail
      Description: Version 1 of the mortgage agent guardrail

Outputs:
  GuardrailArn:
    Value:
      Ref: AgentGuardrail
    Description: ARN of guardrail to associate with agent
  GuardrailVersion:
    Value:
      Fn::GetAtt:
      - AgentGuardrailVersion
      - Version
    Description: Version of guardrail to associate with agent
```

------
#### [ JSON ]

```
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow",
  "Parameters": {
    "GuardrailName": {
      "Type": "String",
      "Description": "Name for guardrail",
      "Default": "MortgageGuardrail"
    }
  },
  "Resources": {
    "AgentGuardrail": {
      "Type": "AWS::Bedrock::Guardrail",
      "Properties": {
        "Name": {
          "Fn::Sub": "AWSDocsTutorial-${GuardrailName}"
        },
        "Description": "Guardrail for mortgage processing with investment advice blocking, content filtering, and PII protection",
        "BlockedInputMessaging": "Sorry, the model cannot answer this question.",
        "BlockedOutputsMessaging": "Sorry, the model cannot answer this question.",
        "TopicPolicyConfig": {
          "TopicsConfig": [
            {
              "Name": "InvestmentAdvice",
              "Definition": "Investment advice refers to inquires, guidance or recommendations regarding the management or allocation of fund or asset with the goal of generating returns or achieving specific financial objectives",
              "Examples": [
                "Is investing in the stocks better than bonds?",
                "Should I invest in gold?"
              ],
              "Type": "DENY"
            }
          ]
        },
        "ContentPolicyConfig": {
          "FiltersConfig": [
            {
              "Type": "VIOLENCE",
              "InputStrength": "HIGH",
              "OutputStrength": "HIGH"
            },
            {
              "Type": "PROMPT_ATTACK",
              "InputStrength": "HIGH",
              "OutputStrength": "NONE"
            },
            {
              "Type": "MISCONDUCT",
              "InputStrength": "HIGH",
              "OutputStrength": "HIGH"
            },
            {
              "Type": "HATE",
              "InputStrength": "HIGH",
              "OutputStrength": "HIGH"
            },
            {
              "Type": "SEXUAL",
              "InputStrength": "HIGH",
              "OutputStrength": "HIGH"
            },
            {
              "Type": "INSULTS",
              "InputStrength": "HIGH",
              "OutputStrength": "HIGH"
            }
          ]
        },
        "WordPolicyConfig": {
          "WordsConfig": [
            {
              "Text": "crypto currency"
            },
            {
              "Text": "bitcoin"
            }
          ],
          "ManagedWordListsConfig": [
            {
              "Type": "PROFANITY"
            }
          ]
        },
        "SensitiveInformationPolicyConfig": {
          "PiiEntitiesConfig": [
            {
              "Type": "EMAIL",
              "Action": "ANONYMIZE"
            },
            {
              "Type": "CREDIT_DEBIT_CARD_NUMBER",
              "Action": "BLOCK"
            }
          ]
        },
        "ContextualGroundingPolicyConfig": {
          "FiltersConfig": [
            {
              "Type": "GROUNDING",
              "Threshold": 0.85
            },
            {
              "Type": "RELEVANCE",
              "Threshold": 0.5
            }
          ]
        }
      }
    },
    "AgentGuardrailVersion": {
      "Type": "AWS::Bedrock::GuardrailVersion",
      "Properties": {
        "GuardrailIdentifier": {
          "Ref": "AgentGuardrail"
        },
        "Description": "Version 1 of the mortgage agent guardrail"
      }
    }
  },
  "Outputs": {
    "GuardrailArn": {
      "Value": {
        "Ref": "AgentGuardrail"
      },
      "Description": "ARN of guardrail to associate with agent"
    },
    "GuardrailVersion": {
      "Value": {
        "Fn::GetAtt": [
          "AgentGuardrailVersion",
          "Version"
        ]
      },
      "Description": "Version of guardrail to associate with agent"
    }
  }
}
```

------

## Amazon Bedrock Prompt management stack
<a name="getting-started-mortgage-prompts-templates"></a>

This stack creates the following [prompt](prompt-management.md) ([AWS::IAM::Prompt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide                     /aws-resource-bedrock-prompt.html)) resources, which are added to the flow:
+ RejectionPrompt – A prompt that returns a generated rejection letter based on financial information.
+ ProcessApplicationPrompt – A prompt that sends a customer's financial information to an agent and prompts the agent to assess whether the customer qualifies for a loan.

------
#### [ YAML ]

```
AWSTemplateFormatVersion: "2010-09-09"
Description: "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow"

Resources:
  RejectionPrompt:
    Type: AWS::Bedrock::Prompt
    Properties:
      Name: !Sub AWSDocsTutorial-RejectionPrompt
      Description: "Use this prompt to generate a rejection letter triggered by an unsatisfactory income to debt ratio"
      DefaultVariant: variantOne
      Variants:
        - Name: variantOne
          TemplateType: TEXT
          ModelId: anthropic.claude-3-haiku-20240307-v1:0
          TemplateConfiguration:
            Text:
              Text: |
                Write a mortgage loan rejection letter for a candiate with income {{income}}, totalDebt {{totalDebt}}, loanAmount {{loanAmount}}. 
                The reason for rejection is their income to debt ratio. 
                Do not mention any other reason. 
                Make the letter as concise as possible. 
                Treat all numeric inputs as whole numbers.
                Let the general structure be like the below:

                Dear [Applicant's Name],
                We appreciate your interest in obtaining a mortgage loan with our institution...
                The primary reason for this decision is that ...
                While we understand that this news may be disappointing, ...
                Thank you again for your interest, and we wish you the best in your future endeavors...

                Sincerely,
                [Your Institution's Name]
              InputVariables:
                - Name: income
                - Name: totalDebt
                - Name: loanAmount
          InferenceConfiguration:
            Text:
              MaxTokens: 2000
              Temperature: 0.0
              TopP: 0.999
              StopSequences:
                - "\n\nHuman:"
          AdditionalModelRequestFields:
            top_k: 250

  ProcessApplicationPrompt:
    Type: AWS::Bedrock::Prompt
    Properties:
      Name: !Sub AWSDocsTutorial-ProcessApplicationPrompt
      Description: "Use this prompt to generate a question for an agent to process the mortgage application"
      DefaultVariant: variantOne
      Variants:
        - Name: variantOne
          TemplateType: TEXT
          ModelId: anthropic.claude-3-haiku-20240307-v1:0
          TemplateConfiguration:
            Text:
              Text: |
                Generate a question asking if the user will qualify for a loan for the specified criteria. 

                Include instruction to base the answer on key features of the property retrieved from MLS listing. 

                Start with "will an applicant...".

                { "income": {{income}}, "creditScore": {{creditScore}}, "totalDebt": {{totalDebt}}, "loanAmount": {{loanAmount}}, "mlsId": {{mlsId}} }

                Include a second question on loan requirements an applicant with the below attributes should consider for a Fannie Mae backed loan (other than debt to income).
              InputVariables:
                - Name: income
                - Name: creditScore
                - Name: totalDebt
                - Name: loanAmount
                - Name: mlsId
          InferenceConfiguration:
            Text:
              MaxTokens: 2000
              Temperature: 0.0
              TopP: 0.999
              StopSequences:
                - "\n\nHuman:"
          AdditionalModelRequestFields:
            top_k: 250

Outputs:
  ProcessApplicationPromptArn:
    Value:
      Ref: ProcessApplicationPrompt
    Description: ARN of the prompt to process a mortgage application
  RejectionPromptArn:
    Value:
      Ref: RejectionPrompt
    Description: ARN of the prompt to reject a mortgage application
```

------
#### [ JSON ]

```
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow",
  "Resources": {
    "RejectionPrompt": {
      "Type": "AWS::Bedrock::Prompt",
      "Properties": {
        "Name": {
          "Fn::Sub": "AWSDocsTutorial-RejectionPrompt"
        },
        "Description": "Use this prompt to generate a rejection letter triggered by an unsatisfactory income to debt ratio",
        "DefaultVariant": "variantOne",
        "Variants": [
          {
            "Name": "variantOne",
            "TemplateType": "TEXT",
            "ModelId": "anthropic.claude-3-haiku-20240307-v1:0",
            "TemplateConfiguration": {
              "Text": {
                "Text": "Write a mortgage loan rejection letter for a candiate with income {{income}}, totalDebt {{totalDebt}}, loanAmount {{loanAmount}}. \nThe reason for rejection is their income to debt ratio. \nDo not mention any other reason. \nMake the letter as concise as possible. \nTreat all numeric inputs as whole numbers.\nLet the general structure be like the below:\n\nDear [Applicant's Name],\nWe appreciate your interest in obtaining a mortgage loan with our institution...\nThe primary reason for this decision is that ...\nWhile we understand that this news may be disappointing, ...\nThank you again for your interest, and we wish you the best in your future endeavors...\n\nSincerely,\n[Your Institution's Name]\n",
                "InputVariables": [
                  {
                    "Name": "income"
                  },
                  {
                    "Name": "totalDebt"
                  },
                  {
                    "Name": "loanAmount"
                  }
                ]
              }
            },
            "InferenceConfiguration": {
              "Text": {
                "MaxTokens": 2000,
                "Temperature": 0.0,
                "TopP": 0.999,
                "StopSequences": [
                  "\n\nHuman:"
                ]
              }
            },
            "AdditionalModelRequestFields": {
              "top_k": 250
            }
          }
        ]
      }
    },
    "ProcessApplicationPrompt": {
      "Type": "AWS::Bedrock::Prompt",
      "Properties": {
        "Name": {
          "Fn::Sub": "AWSDocsTutorial-ProcessApplicationPrompt"
        },
        "Description": "Use this prompt to generate a question for an agent to process the mortgage application",
        "DefaultVariant": "variantOne",
        "Variants": [
          {
            "Name": "variantOne",
            "TemplateType": "TEXT",
            "ModelId": "anthropic.claude-3-haiku-20240307-v1:0",
            "TemplateConfiguration": {
              "Text": {
                "Text": "Generate a question asking if the user will qualify for a loan for the specified criteria. \n\nInclude instruction to base the answer on key features of the property retrieved from MLS listing. \n\nStart with \"will an applicant...\".\n\n{ \"income\": {{income}}, \"creditScore\": {{creditScore}}, \"totalDebt\": {{totalDebt}}, \"loanAmount\": {{loanAmount}}, \"mlsId\": {{mlsId}} }\n\nInclude a second question on loan requirements an applicant with the below attributes should consider for a Fannie Mae backed loan (other than debt to income).\n",
                "InputVariables": [
                  {
                    "Name": "income"
                  },
                  {
                    "Name": "creditScore"
                  },
                  {
                    "Name": "totalDebt"
                  },
                  {
                    "Name": "loanAmount"
                  },
                  {
                    "Name": "mlsId"
                  }
                ]
              }
            },
            "InferenceConfiguration": {
              "Text": {
                "MaxTokens": 2000,
                "Temperature": 0.0,
                "TopP": 0.999,
                "StopSequences": [
                  "\n\nHuman:"
                ]
              }
            },
            "AdditionalModelRequestFields": {
              "top_k": 250
            }
          }
        ]
      }
    }
  },
  "Outputs": {
    "ProcessApplicationPromptArn": {
      "Value": {
        "Ref": "ProcessApplicationPrompt"
      },
      "Description": "ARN of the prompt to process a mortgage application"
    },
    "RejectionPromptArn": {
      "Value": {
        "Ref": "RejectionPrompt"
      },
      "Description": "ARN of the prompt to reject a mortgage application"
    }
  }
}
```

------

## Amazon Bedrock Knowledge Bases stack
<a name="getting-started-mortgage-kb-templates"></a>

This template creates the [knowledge base](knowledge-base.md) and its data source containing the loan guidelines:
+ KnowledgeBase ([AWS::Bedrock::KnowledgeBase](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide                         /aws-resource-bedrock-knowledgebase.html))
+ KnowledgeBaseDataSource ([AWS::Bedrock::DataSource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide                         /aws-resource-bedrock-datasource.html))

------
#### [ YAML ]

```
AWSTemplateFormatVersion: '2010-09-09'
Description: "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow"
Parameters:
  KnowledgeBaseName:
    Type: String
    Description: Name of knowledge base
    Default: MortgageKB
  Q01pS3BucketName:
    Type: String
    Description: Name of S3 bucket where knowledge base data is stored
  Q06pKBEmbedModel:
    Type: String
    Description: Selected Embedding model
  Q07pKBChunkingStrategy:
    Type: String
    Description: Selected Chunking strategy
  Q08pKBMaxTokens:
    Type: Number
    Description: Maximum number of tokens in a chunk
  Q09pKBOverlapPercentage:
    Type: Number
    Description: Percent overlap in each chunk
  Q11pOSSCollectionName:
    Type: String
    Description: Name of the Collection
  Q12pOSSIndexName:
    Type: String
    Description: Index name to be created in vector store
  Q13pVectorFieldName:
    Type: String
    Description: Vector field name
    Default: bedrock-knowledge-base-default-vector
  Q14pMetaDataFieldName:
    Type: String
    Description: Metadata field name
    Default: AMAZON_BEDROCK_METADATA
  Q15pTextFieldName:
    Type: String
    Description: Text field name
    Default: AMAZON_BEDROCK_TEXT_CHUNK
  pCollectionArn:
    Type: String
    Description: Name of the Collection Arn
  pKBRole:
    Type: String
    Description: KB role for e2e RAG
  pKBRoleArn:
    Type: String
    Description: KB role Arn for e2e RAG
Conditions:
  IsChunkingStrategyFixed:
    Fn::Equals:
      - Ref: Q07pKBChunkingStrategy
      - Fixed-size chunking
  IsChunkingStrategyDefault:
    Fn::Equals:
      - Ref: Q07pKBChunkingStrategy
      - Default chunking
  IsChunkingStrategyNoChunking:
    Fn::Equals:
      - Ref: Q07pKBChunkingStrategy
      - No chunking
  IsChunkingStrategyFixedOrDefault:
    Fn::Or:
      - Condition: IsChunkingStrategyFixed
      - Condition: IsChunkingStrategyDefault
Resources:
  KnowledgeBase:
    Type: AWS::Bedrock::KnowledgeBase
    Properties:
      Description: Test KB Deployment
      KnowledgeBaseConfiguration:
        Type: VECTOR
        VectorKnowledgeBaseConfiguration:
          EmbeddingModelArn:
            Fn::Sub: arn:aws:bedrock:${AWS::Region}::foundation-model/${Q06pKBEmbedModel}
      Name: !Sub AWSDocsTutorial-${KnowledgeBaseName}
      RoleArn:
        Ref: pKBRoleArn
      StorageConfiguration:
        OpensearchServerlessConfiguration:
          CollectionArn:
            Ref: pCollectionArn
          FieldMapping:
            MetadataField:
              Ref: Q14pMetaDataFieldName
            TextField:
              Ref: Q15pTextFieldName
            VectorField:
              Ref: Q13pVectorFieldName
          VectorIndexName:
            Ref: Q12pOSSIndexName
        Type: OPENSEARCH_SERVERLESS

  KnowledgeBaseDataSource:
    Type: AWS::Bedrock::DataSource
    DependsOn:
    - KnowledgeBase
    Properties:
      DataSourceConfiguration:
        Type: S3
        S3Configuration:
          BucketArn:
            Fn::Sub: arn:aws:s3:::${Q01pS3BucketName}
          InclusionPrefixes:
            - knowledge-base-data-source/
      Description: Knowledge base data source
      KnowledgeBaseId:
        Ref: KnowledgeBase
      Name: !Sub AWSDocsTutorial-${KnowledgeBaseName}-DS
      VectorIngestionConfiguration:
        ChunkingConfiguration:
          Fn::If:
            - IsChunkingStrategyFixed
            - ChunkingStrategy: FIXED_SIZE
              FixedSizeChunkingConfiguration:
                MaxTokens: !Ref Q08pKBMaxTokens
                OverlapPercentage: !Ref Q09pKBOverlapPercentage
            - Fn::If:
                - IsChunkingStrategyDefault
                - ChunkingStrategy: FIXED_SIZE
                  FixedSizeChunkingConfiguration:
                    MaxTokens: 300
                    OverlapPercentage: 20
                - Fn::If:
                    - IsChunkingStrategyNoChunking
                    - ChunkingStrategy: NONE
                    - !Ref AWS::NoValue
Outputs:
  KBId:
    Value:
      Ref: KnowledgeBase
    Description: KnowledgeBase ID
  DS:
    Value:
      Ref: KnowledgeBaseDataSource
    Description: KnowledgeBase Datasource
```

------
#### [ JSON ]

```
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "[AWSDocs] AmazonBedrockDocs: getting-started-mortgage-flow",
  "Parameters": {
    "KnowledgeBaseName": {
      "Type": "String",
      "Description": "Name of knowledge base",
      "Default": "MortgageKB"
    },
    "Q01pS3BucketName": {
      "Type": "String",
      "Description": "Name of S3 bucket where knowledge base data is stored"
    },
    "Q06pKBEmbedModel": {
      "Type": "String",
      "Description": "Selected Embedding model"
    },
    "Q07pKBChunkingStrategy": {
      "Type": "String",
      "Description": "Selected Chunking strategy"
    },
    "Q08pKBMaxTokens": {
      "Type": "Number",
      "Description": "Maximum number of tokens in a chunk"
    },
    "Q09pKBOverlapPercentage": {
      "Type": "Number",
      "Description": "Percent overlap in each chunk"
    },
    "Q11pOSSCollectionName": {
      "Type": "String",
      "Description": "Name of the Collection"
    },
    "Q12pOSSIndexName": {
      "Type": "String",
      "Description": "Index name to be created in vector store"
    },
    "Q13pVectorFieldName": {
      "Type": "String",
      "Description": "Vector field name",
      "Default": "bedrock-knowledge-base-default-vector"
    },
    "Q14pMetaDataFieldName": {
      "Type": "String",
      "Description": "Metadata field name",
      "Default": "AMAZON_BEDROCK_METADATA"
    },
    "Q15pTextFieldName": {
      "Type": "String",
      "Description": "Text field name",
      "Default": "AMAZON_BEDROCK_TEXT_CHUNK"
    },
    "pCollectionArn": {
      "Type": "String",
      "Description": "Name of the Collection Arn"
    },
    "pKBRole": {
      "Type": "String",
      "Description": "KB role for e2e RAG"
    },
    "pKBRoleArn": {
      "Type": "String",
      "Description": "KB role Arn for e2e RAG"
    }
  },
  "Conditions": {
    "IsChunkingStrategyFixed": {
      "Fn::Equals": [
        {
          "Ref": "Q07pKBChunkingStrategy"
        },
        "Fixed-size chunking"
      ]
    },
    "IsChunkingStrategyDefault": {
      "Fn::Equals": [
        {
          "Ref": "Q07pKBChunkingStrategy"
        },
        "Default chunking"
      ]
    },
    "IsChunkingStrategyNoChunking": {
      "Fn::Equals": [
        {
          "Ref": "Q07pKBChunkingStrategy"
        },
        "No chunking"
      ]
    },
    "IsChunkingStrategyFixedOrDefault": {
      "Fn::Or": [
        {
          "Condition": "IsChunkingStrategyFixed"
        },
        {
          "Condition": "IsChunkingStrategyDefault"
        }
      ]
    }
  },
  "Resources": {
    "KnowledgeBase": {
      "Type": "AWS::Bedrock::KnowledgeBase",
      "Properties": {
        "Description": "Test KB Deployment",
        "KnowledgeBaseConfiguration": {
          "Type": "VECTOR",
          "VectorKnowledgeBaseConfiguration": {
            "EmbeddingModelArn": {
              "Fn::Sub": "arn:aws:bedrock:${AWS::Region}::foundation-model/${Q06pKBEmbedModel}"
            }
          }
        },
        "Name": {
          "Fn::Sub": "AWSDocsTutorial-${KnowledgeBaseName}"
        },
        "RoleArn": {
          "Ref": "pKBRoleArn"
        },
        "StorageConfiguration": {
          "OpensearchServerlessConfiguration": {
            "CollectionArn": {
              "Ref": "pCollectionArn"
            },
            "FieldMapping": {
              "MetadataField": {
                "Ref": "Q14pMetaDataFieldName"
              },
              "TextField": {
                "Ref": "Q15pTextFieldName"
              },
              "VectorField": {
                "Ref": "Q13pVectorFieldName"
              }
            },
            "VectorIndexName": {
              "Ref": "Q12pOSSIndexName"
            }
          },
          "Type": "OPENSEARCH_SERVERLESS"
        }
      }
    },
    "KnowledgeBaseDataSource": {
      "Type": "AWS::Bedrock::DataSource",
      "DependsOn": [
        "KnowledgeBase"
      ],
      "Properties": {
        "DataSourceConfiguration": {
          "Type": "S3",
          "S3Configuration": {
            "BucketArn": {
              "Fn::Sub": "arn:aws:s3:::${Q01pS3BucketName}"
            },
            "InclusionPrefixes": [
              "knowledge-base-data-source/"
            ]
          }
        },
        "Description": "Knowledge base data source",
        "KnowledgeBaseId": {
          "Ref": "KnowledgeBase"
        },
        "Name": {
          "Fn::Sub": "AWSDocsTutorial-${KnowledgeBaseName}-DS"
        },
        "VectorIngestionConfiguration": {
          "ChunkingConfiguration": {
            "Fn::If": [
              "IsChunkingStrategyFixed",
              {
                "ChunkingStrategy": "FIXED_SIZE",
                "FixedSizeChunkingConfiguration": {
                  "MaxTokens": {
                    "Ref": "Q08pKBMaxTokens"
                  },
                  "OverlapPercentage": {
                    "Ref": "Q09pKBOverlapPercentage"
                  }
                }
              },
              {
                "Fn::If": [
                  "IsChunkingStrategyDefault",
                  {
                    "ChunkingStrategy": "FIXED_SIZE",
                    "FixedSizeChunkingConfiguration": {
                      "MaxTokens": 300,
                      "OverlapPercentage": 20
                    }
                  },
                  {
                    "Fn::If": [
                      "IsChunkingStrategyNoChunking",
                      {
                        "ChunkingStrategy": "NONE"
                      },
                      {
                        "Ref": "AWS::NoValue"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        }
      }
    }
  },
  "Outputs": {
    "KBId": {
      "Value": {
        "Ref": "KnowledgeBase"
      },
      "Description": "KnowledgeBase ID"
    },
    "DS": {
      "Value": {
        "Ref": "KnowledgeBaseDataSource"
      },
      "Description": "KnowledgeBase Datasource"
    }
  }
}
```

------

# Details about the mortgage processing flow
<a name="getting-started-mortgage-flow-details"></a>

The visual representation of the mortgage processing flow in the AWS Management Console is as follows:

![\[Mortgage processing flow\]](http://docs.aws.amazon.com/bedrock/latest/userguide/images/cloudformation/mortgage-processing-flow.png)


## Steps in the flow
<a name="getting-started-mortgage-flow-steps"></a>

The following steps occur in the flow:

1. The customer's financial information from the input is sent to the `loanCalculator` Lambda function, which calculates the customer's maximum affordable loan.

1. The output from the `loanCalculator` function (`maximumAffordableLoan`) and the `loanAmount` value from the input are sent to the condition node, which is then evaluated as follows:
   + If the `loanAmount` is greater than the `maximumAffordableLoan`, the `incomeDebt` prompt is triggered and a rejection letter for the loan is generated.
   + Otherwise, the customer's financial information is sent to the `mortgageProcessingAgent` by the `processApplication` prompt. The agent applies a loan calculator function, as well as a Multiple Listing Service (MLS) lookup function to look up a DynamoDB table and assess the customer's information with respect to the MLS property specified in the input. Furthermore, the agent looks up information from a knowledge base, which contains the Fannie Mae Selling Guide. The agent uses all this information to generate a response analyzing the customer's eligibility for the requested loan amount.

# Document history for the Amazon Bedrock User Guide
<a name="doc-history"></a>
+ **Latest documentation update: **November 26th, 2025

The following table describes important changes in each release of Amazon Bedrock. For notification about updates to this documentation, you can subscribe to an RSS feed.

| Change | Description | Date | 
| --- |--- |--- |
| [Converse API support for batch inference](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-create.html) | You can now use the Converse API format for batch inference input data. When creating a batch inference job, set the model invocation type to Converse to use a consistent request format across models. | February 27, 2026 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/fine-tuning-openai-apis.html) | Added support for fine-tuning open-weight models using OpenAI-compatible APIs. You can now create, monitor, and manage reinforcement fine-tuning jobs for open-weight models through familiar OpenAI SDK endpoints, including Files API, fine-tuning jobs APIs, and inference APIs. | February 17, 2026 | 
| [Updated list of models supported for service tiers](https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html) | Updated list of models supported for priority and flex service tiers | December 31, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/bda-optimize-blueprint-info.html) | Amazon Bedrock Data Automation now supports blueprint instruction optimization for documents. Improve Data Automation custom output accuracy by providing example content assets with ground truth labels, enabling you to achieve production-ready accuracy for documents in minutes without model training. | December 18, 2025 | 
| [New managed policies](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html) | Amazon Bedrock added the following managed IAM policies for Amazon Bedrock Mantle: AmazonBedrockMantleFullAccess, AmazonBedrockMantleReadOnly, AmazonBedrockMantleInferenceAccess. Amazon Bedrock Mantle provides OpenAI-compatible API endpoints for model inference. | December 3, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-mantle.html) | Amazon Bedrock now supports OpenAI compatible API endpoints, including Responses API and Chat Completions API. These endpoints enable asynchronous inference for long-running workloads, stateful conversation management without manual history passing, and simplified tool use integration for agentic workflows. Migrate existing applications with minimal code changes by updating your base URL and API key. | December 3, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/reinforcement-fine-tuning.html) | Added new reinforcement fine-tuning to improve foundation model performance through feedback signals. | December 3, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-service-tiers.html) | Added new "Reserved" service tier for Bedrock inference. | November 26, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html) | Amazon Bedrock now supports Anthropic Claude Opus 4.5. | November 24, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-enforcements.html) | You can now share guardrails across accounts within an AWS organization. | November 21, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/bda-using-api.html) | Amazon Bedrock Data Automation now supports synchronous invocation. | November 20, 2025 | 
| [Updated model support for custom model import](https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-import-model.html) | Custom model import now supports OpenAI GPT-OSS models. | November 19, 2025 | 
| [Enhanced coding use case support for Standard tier](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html) | Amazon Bedrock Guardrails Standard tier now provides enhanced support for coding use cases. Content filters, prompt attacks, and denied topics have been upgraded to better handle code-related prompts and responses without requiring changes to existing configurations. Added comprehensive code domain support documentation and prompt leakage detection for Standard tier. | November 19, 2025 | 
| [Updated feature](https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html) | Added new service tiers priority and flex for on demand inference | November 18, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | Amazon Bedrock is now supported in Africa (Cape Town), Asia Pacific (New Zealand), Canada West (Calgary), Mexico (Central), and Middle East (Bahrain). | November 18, 2025 | 
| [Updated feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-vector-stores.html) | Added note about using 'english' dictionary instead of 'simple' dictionary for PostgreSQL text search in Aurora Knowledge Base integration. | October 31, 2025 | 
| [Model in legacy status](https://docs.aws.amazon.com/bedrock/latest/userguide/model-lifecycle.html) | Anthropic Claude 3.7 Sonnet is now in legacy status. Migrate to Claude Sonnet 4.5 before April 28, 2026. | October 30, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/stable-image-services.html) | Four new Stability AI Image Services (outpaint and upscale) are now available with Amazon Bedrock. | October 28, 2025 | 
| [Updated feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-submit.html) | You can now use a previously customized model (fine-tuned or distilled) as the base model for further customization. | October 16, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude Haiku 4.5 with Amazon Bedrock. | October 15, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) | Access to all Amazon Bedrock foundation models is now enabled by default with the correct IAM permissions. | October 15, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region-support.html) | Amazon Bedrock Guardrails is now generally available with cross-region inference in 5 additional regions: Asia Pacific (Bangkok), Asia Pacific (Kuala Lumpur), Asia Pacific (Taipei), Israel (Tel Aviv), and Middle East (Dubai). | October 9, 2025 | 
| [Updated managed policy](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html) | Amazon Bedrock updated the AmazonBedrockFullAccess managed policy to enable access to all serverless foundation models by default. | October 7, 2025 | 
| [Updated model support for batch inference](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | Batch inference now supports DeepSeek V3.1, Qwen3 32B (dense), Qwen3 235B A22B 2507, Qwen3-Coder-30B-A3B-Instruct, and Qwen3 Coder 480B A35B Instruct. | October 3, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-embed.html) | You can now use Cohere Cohere Embed v4 with Amazon Bedrock. | October 2, 2025 | 
| [Updated model support](https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-import-model.html) | You can now import Qwen3 models with model import. | September 30, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-supported.html) | Cohere Cohere Rerank 3.5 model is now available in US East (N. Virginia). | September 30, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region.html) | Amazon Bedrock Guardrails is now available generally in Asia Pacific (Melbourne) and with cross-Region inference. | September 29, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude Sonnet 4.5 with Amazon Bedrock. | September 29, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock is now available in Asia Pacific (Thailand), Asia Pacific (Taipei), Asia Pacific (Malaysia), Middle East (UAE), and Israel (Tel Aviv). | September 26, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows.html) | Amazon Bedrock Flows now supports Flows trace enhancements and DoWhile loop node functionality. | September 26, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude Sonnet 4.5 with Amazon Bedrock. | September 25, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/stable-image-services.html) | Stability AI Image Services are now available with Amazon Bedrock. | September 18, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-model-supported.html) | Meta Llama 3.3 70B Instruct is now available for fine-tuning and continued pretraining is now available with Amazon Bedrock. | September 15, 2025 | 
| [New Region support for Guardrails](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-supporte.html) | Amazon Bedrock Guardrails is now supported in Asia Pacific (Jakarta). | September 11, 2025 | 
| [New tutorial](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-marengo.html) | TwelveLabs Marengo Embed 2.7 now supports the [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html) API. | September 9, 2025 | 
| [New tutorial](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-permissions.html) | You can now use the `bedrock:bearerTokenType` condition key with the `bedrock:CallWithBearerToken` action. | September 4, 2025 | 
| [New tutorial](https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started-mortgage-flow.html) | You can familiarize yourself with Amazon Bedrock resource creation by trying out a tutorial to easily set up a mortgage Amazon Bedrock flow with CloudFormation templates. | September 2, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-openai-batch.html) | The OpenAI batch API is now supported. | August 27, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation is now available in AWS GovCloud (US-West). | August 25, 2025 | 
| [New languages](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation now supports data extraction from documents in Portuguese, French, Italian, Spanish, and German. | August 25, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/count-tokens.html) | You can now estimate token count for some models. | August 21, 2025 | 
| [Region expansion for model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | TwelveLabs TwelveLabs Pegasus 1.2 is now supported in US East (N. Virginia) and Asia Pacific (Seoul). | August 14, 2025 | 
| [Added model support for Amazon Bedrock Guardrails](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-supported.html) | Amazon Bedrock Guardrails is now supported in US West (N. California). | August 11, 2025 | 
| [New models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use OpenAI gpt-oss-20b and gpt-oss-120b with Amazon Bedrock. | August 5, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-automated-reasoning-checks.html) | Amazon Bedrock Guardrails now supports Automated Reasoning checks to validate the accuracy of foundation model responses. | August 5, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | Amazon Bedrock is now supported in Asia Pacific (Melbourne). | July 31, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude Opus 4.1 with Amazon Bedrock. | July 31, 2025 | 
| [Added model support for batch inference](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | Batch inference now supports the US Amazon Nova Premier inference profile. | July 29, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | Amazon Bedrock is now supported in US West (N. California). | July 28, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation now supports DOC/DOCX and H.265 file types | July 28, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation is now available in Europe (Frankfurt), Europe (London), Europe (Ireland), Asia Pacific (Mumbai), and Asia Pacific (Sydney). | July 16, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/import-with-create-custom-model.html) | You can now import SageMaker AI-trained Amazon Nova models into Amazon Bedrock as custom models. | July 16, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/deploy-custom-model-on-demand.html) | You can now deploy custom models for on-demand inference in Amazon Bedrock. This feature allows you to deploy custom models for pay-per-token inference without provisioned throughput. | July 16, 2025 | 
| [New models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use TwelveLabs TwelveLabs Pegasus 1.2 and TwelveLabs Marengo Embed 2.7 with Amazon Bedrock. | July 15, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude 3.7 Sonnet in AWS GovCloud (US-West). | July 7, 2025 | 
| [New managed policies](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html) | Amazon Bedrock added the following managed IAM policies: AmazonBedrockLimitedAccess, AmazonBedrockMarketplaceAccess. | July 7, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html) | Amazon Bedrock now supports the creation of API keys for easy authentication to make calls to the Amazon Bedrock API. | July 7, 2025 | 
| [Region expansion for intelligent prompt routing](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | Intelligent prompt routing is now supported in AWS GovCloud (US-West) and AWS GovCloud (US-East). | July 3, 2025 | 
| [Added model support for batch inference](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | Batch inference is now supported by the Meta Llama 4 Scout 17B Instruct and Llama 4 Maverick 17B Instruct models. | July 3, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-supported.html) | Prompt management is now supported in Europe (Milan), Europe (Spain), Asia Pacific (Hyderabad), and Asia Pacific (Osaka). | July 1, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-supported.html) | Amazon Bedrock Flows is now supported in Europe (Milan), Europe (Spain), Asia Pacific (Hyderabad), and Asia Pacific (Osaka). | July 1, 2025 | 
| [Region expansion for Amazon Bedrock Knowledge Bases](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-supported.html) | Amazon Bedrock Knowledge Bases is now supported in the AWS Regions Asia Pacific (Hyderabad), Asia Pacific (Osaka), Europe (Milan), and Europe (Spain). | June 26, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-tiers.html) | Amazon Bedrock Guardrails supports safeguard tiers, which give you performance and language options for content filters (text), prompt attacks, and denied topic policies. | June 23, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-nodes.html) | (Preview) Run code directly in your Amazon Bedrock flow with inline code nodes. | June 19, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-create-async.html) | (Preview) Run Amazon Bedrock flows for longer durations with flow executions. | June 19, 2025 | 
| [New tutorial](https://docs.aws.amazon.com/bedrock/latest/userguide/agent-tutorial.html) | Added a tutorial for creating a simple Amazon Bedrock agent. | May 28, 2025 | 
| [New models available](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can know use Claude Sonnet 4 and Claude Opus 4 with Amazon Bedrock. | May 22, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation now supports custom output for videos. | May 19, 2025 | 
| [Added video blueprint support](https://docs.aws.amazon.com/bedrock/latest/userguide/creating-blueprint-video.html) | BDA now supports blueprints for videos. | May 16, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-cross-region.html) | Amazon Bedrock Guardrails now supports cross-Region inference. | May 13, 2025 | 
| [Added model support for custom model import](https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-import-model.html) | Custom model import now supports Qwen2, Qwen2.5, Qwen2-VL, Qwen2.5-VL. | May 12, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation now supports custom blueprints for audio files. | May 5, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Meta Llama 4 Scout 17B Instruct and Llama 4 Maverick 17B Instruct with Amazon Bedrock.  | April 28, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Writer Palmyra X4 and Writer Palmyra X5 with Amazon Bedrock.  | April 28, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-call.html) | You can now reference images and documents stored in Amazon S3 when using the InvokeModel and Converse APIs with Amazon Nova Lite and Amazon Nova Pro. Inclusion of images, documents, and videos stored in S3 with these APIs is also now supported with inference profiles. | April 25, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation now supports modality routing and hyperlink support | April 25, 2025 | 
| [General release](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-routing.html) | Intelligent prompt routing is now generally available with Amazon Bedrock. | April 22, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup.html) | Amazon Bedrock Knowledge Bases now supports additional user-provided metadata field for Amazon Aurora and enhanced hybrid search capabilities for MongoDB vector stores. | April 10, 2025 | 
| [Region expansion for custom model import](https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-import-model.html) | Custom model import is now supported in Europe (Frankfurt). | April 9, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Pixtral Large (25.02) with Amazon Bedrock.  | April 8, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-harmful-content-handling-options.html) | New options for handling harmful content detected by Amazon Bedrock. | April 7, 2025 | 
| [Region expansion for batch inference](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | Batch inference now supports Amazon Nova Lite, Amazon Nova Pro, and Amazon Nova Micro in AWS GovCloud (US-West). | April 4, 2025 | 
| [Region expansion for batch inference](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | Batch inference now supports Anthropic Claude Claude 3.5 Sonnet V2 in Asia Pacific (Mumbai), Asia Pacific (Hyderabad), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Seoul), Asia Pacific (Osaka) and Amazon Titan Text Embeddings V2 in Europe (Stockholm), Europe (Milan), and Europe (Spain). | April 2, 2025 | 
| [Added model support for Provisioned Throughput](https://docs.aws.amazon.com/bedrock/latest/userguide/pt-supported.html) | Provisioned Throughput now supports Amazon Nova Canvas, in addition to 24k context windows for Amazon Nova Lite, Amazon Nova Micro, and Amazon Nova Pro. | April 2, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-osm-permissions-prereq.html) | Amazon Bedrock Knowledge Bases now supports OpenSearch Managed Clusters as a vector store when creating a knowledge base. | March 27, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-templates.html) | You can now use flow templates to get started with Amazon Bedrock Flows. | March 27, 2025 | 
| [Feature moved](#doc-history) | Amazon Bedrock Studio, renamed to Amazon Bedrock in Sagemaker Unified Studio, is now available in [Amazon SageMaker Unified Studio](https://docs.aws.amazon.com/sagemaker-unified-studio/latest/userguide/what-is-sagemaker-unified-studio.html). | March 25, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-permissions.html#guardrails-permissions-id) | You can now enforce Amazon Bedrock model inference requests to use specific guardrails through a new IAM condition key. | March 18, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bedrock_region) | Amazon Bedrock is now supported in Europe (Milan) and Europe (Spain). | March 14, 2025 | 
| [Support expanded for feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-generate-query.html) | Amazon Bedrock Knowledge Bases now supports cross-region inference with structured data retrieval. | March 13, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-routing.html) | Amazon Bedrock now supports configured prompt routers in preview with intelligent prompt routing. | March 13, 2025 | 
| [Model support expanded for feature](https://docs.aws.amazon.com/bedrock/latest/userguide/pt-supported.html) | Provisioned Throughput now supports Llama 3.2 1B Instruct, Llama 3.2 3B Instruct, Llama 3.2 11B Instruct, and Llama 3.2 90B Instruct in US West (Oregon). | March 13, 2025 | 
| [Added model support for Knowledge Bases](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-configure-reasoning.html) | Amazon Bedrock Knowledge Bases now supports reasoning models Deepseek-R1 and Anthropic Claude 3.7 Sonnet.  | March 12, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use DeepSeek-R1 with Amazon Bedrock.  | March 10, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-computer-use.html) | You can now configure an Amazon Bedrock Agent to complete tasks with computer use tools. | March 10, 2025 | 
| [General release](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-build-graphs.html) | GraphRAG for Amazon Bedrock Knowledge Bases is now generally available with additional capabilities. | March 7, 2025 | 
| [General release](https://docs.aws.amazon.com/bedrock/latest/userguide/bda.html) | Amazon Bedrock data automation is now available with increased accuracy and CRIS | March 3, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bedrock_region) | Amazon Bedrock is now supported in Europe (Stockholm). | February 27, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/sessions.html) | You can now use Amazon Bedrock session management APIs to manage state for generative AI applications built with open-source frameworks. | February 27, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Claude 3.7 Sonnet with Amazon Bedrock.  | February 24, 2025 | 
| [Region expansion](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bedrock_region) | Amazon Bedrock is now supported in Asia Pacific (Hyderabad) and Asia Pacific (Osaka). | February 21, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Cohere Embed English and Cohere Embed Multilingual with Amazon Bedrock.  | January 24, 2025 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Luma Ray v2 with Amazon Bedrock.  | January 23, 2025 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-multi-turn-invocation.html) | You can now converse with an agent node in an Amazon Bedrock flow. | January 22, 2025 | 
| [Updated model support](https://docs.aws.amazon.com/bedrock/latest/userguide/pt-supported.html) | You can now use Llama 3.3 70B Instruct for batch inference in US East (N. Virginia) and US West (Oregon). | December 23, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | You can now use Llama 3.3 70B Instruct for batch inference in US East (N. Virginia) and US West (Oregon). | December 23, 2024 | 
| [New models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Llama 3.3 70B Instruct and Stable Diffusion 3.5 with Amazon Bedrock.  | December 19, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-supported.html) | Amazon Bedrock Guardrails can now be applied to French and Spanish inputs. | December 9, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | You can now run batch inference with an inference profile. | December 6, 2024 | 
| [Updated managed policies](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html) | Amazon Bedrock Marketplace permissions were added to the AmazonBedrockFullAccess and AmazonBedrockReadOnly AWS managed policies. | December 4, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/amazon-bedrock-marketplace.html) | You can now deploy an Amazon Bedrock marketplace model and then run inference with the model. | December 4, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-build-structured.html) | You can now connect knowledge bases to structured data stores and generate SQL queries in Amazon Bedrock Knowledge Bases. | December 4, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-advanced-parsing.html) | You can now parse multimodal data containing images with the Amazon Bedrock Data Automation parser or a foundation model in Amazon Bedrock Knowledge Bases. | December 4, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-mmfilter.html) | Amazon Bedrock Guardrails can now help filter harmful images by using image content filters. | December 4, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-multi-agent-collaboration.html) | Amazon Bedrock Agents now supports multi-agent collaboration that enables multiple Amazon Bedrock Agents to collaboratively plan and solve complex tasks. | December 3, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-distillation.html.html) | You can now transfer knowledge from a larger more intelligent model (known as teacher) to a smaller, faster, cost-efficient model (known as student) and use the distilled student model for your specific use case.  | December 3, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use latency optimized models from Meta and Anthropic in Amazon Bedrock. | December 2, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-retrieve.html) | You can now apply guardrails when you retrieve results from a data source in Amazon Bedrock Knowledge Bases. | December 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-retrieve-generate.html) | You can now use RetrieveAndGenerateStream, a streaming version of RetrieveAndGenerate, in Amazon Bedrock Knowledge Bases. | December 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html) | You can now apply a retrieval filter based on a user query and a metadata schema in Amazon Bedrock Knowledge Bases. | December 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank.html) | You can now use a reranker model to rerank the relevance of source documents based on a user query. | December 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-direct-ingestion.html) | You can now ingest document changes directly into a knowledge base in one step. | December 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-data-source-connector.html) | You can now connect your knowledge base to a custom data source. | December 1, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/features-regions.html) | Europe (Zurich) now supports Amazon Bedrock Agents, Amazon Bedrock Knowledge Bases, Prompt management, and Amazon Bedrock Flows. | November 22, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-supported.html) | Amazon Bedrock Flows is now supported in US East (Ohio), Asia Pacific (Seoul), Canada (Central), Europe (London), and South America (São Paulo). | November 22, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-supported.html) | Prompt management is now supported in US East (Ohio), Asia Pacific (Seoul), Canada (Central), Europe (London), and South America (São Paulo). | November 22, 2024 | 
| [General release](https://docs.aws.amazon.com/bedrock/latest/userguide/flows.html) | Amazon Bedrock Flows is now generally available in Amazon Bedrock. | November 22, 2024 | 
| [Feature update](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base.html) | Amazon Bedrock knowledge bases now support binary embeddings. | November 21, 2024 | 
| [Feature update](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-optimize.html) | Amazon Bedrock Prompt management now supports optimizing prompts. | November 20, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions) | You can now use Amazon Bedrock in AWS GovCloud (US-East) and Europe (Zurich). | November 11, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-supported.html#kb-supported-regions) | Amazon Bedrock now supports knowledge bases in US East (Ohio). | November 8, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-trace.html) | You can now view the trace for a flow to track the inputs and outputs of each node. | November 7, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows-guardrails.html) | You can now include guardrails for a knowledge base or prompt node in a flow. | November 7, 2024 | 
| [General release](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management.html) | Prompt management is now generally available in Amazon Bedrock. | November 7, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html#inference-profiles-support-user) | You can now create application inference profiles in Asia Pacific (Singapore) and Asia Pacific (Seoul). | November 6, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html#inference-profiles-support-system) | Cross-Region inference profiles have been added for Anthropic Claude and Meta Llama models. | November 6, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude 3.5 Haiku with Amazon Bedrock.  | November 4, 2024 | 
| [Feature update](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles.html) | You can now create application inference profiles to run model inference and use them to track costs and metrics. | November 1, 2024 | 
| [Feature update](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-create.html) | You can now include model-specific inference parameters when defining a prompt in Prompt management or in a prompt node in a flow. | October 31, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude 3.5 Sonnet v2 with Amazon Bedrock. You can also use computer use tools with Anthropic Claude 3.5 Sonnet v2.  | October 22, 2024 | 
| [Updated managed policy](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-AmazonBedrockReadOnly) | Read-only permissions for Custom Model Import were added to the AmazonBedrockReadOnly AWS-managed policy. | October 21, 2024 | 
| [Feature update](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-create.html) | The `topK` field is no longer supported in the `inferenceConfiguration` object when creating a prompt in Prompt management. | October 21, 2024 | 
| [Feature update](https://docs.aws.amazon.com/bedrock/latest/userguide/playgrounds.html) | The text and chat playgrounds are now merged into a Chat/text playground in the Amazon Bedrock console. | October 21, 2024 | 
| [Feature update](https://docs.aws.amazon.com/bedrock/latest/userguide/playgrounds.html) | The text and chat playgrounds are now merged into a Chat/text playground in the Amazon Bedrock console. | October 21, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-supported.html) | Batch inference is now supported in Asia Pacific (Seoul). | October 7, 2024 | 
| [New Regions supported](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Amazon Bedrock in AWS Region US East (Ohio) and Asia Pacific (Seoul). | October 1, 2024 | 
| [Model in legacy status](https://docs.aws.amazon.com/bedrock/latest/userguide/model-lifecycle.html) | Anthropic Claude Opus 4 is now in legacy status. Migrate to Claude Opus 4.1 before May 31, 2026. | October 1, 2024 | 
| [New models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Meta Llama 3.2 1B Instruct, Llama 3.2 3B Instruct, Llama 3.2 11B Instruct, and Llama 3.2 90B Instruct models with Amazon Bedrock. | September 25, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-embed-text.html) | You can now use binary embeddings with Titan Text Embeddings V2 model in Amazon Bedrock | September 25, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/monitoring-guardrails-cw-metrics.html) | You can now monitor Guardrails with CloudWatch Metrics in Amazon Bedrock. | September 24, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) | You can now assess an inference profile using model evaluation. | September 24, 2024 | 
| [New models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use AI21 Labs Jamba 1.5 Large and AI21 Labs Jamba 1.5 Mini with Amazon Bedrock. | September 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) | You can now use an inference profile when using a prompt in Prompt management or including a prompt in a flow. | September 23, 2024 | 
| [More model support for Provisioned Throughput](https://docs.aws.amazon.com/bedrock/latest/userguide/pt-supported.html) | You can now purchase Provisioned Throughput for Anthropic Claude 3.5 Sonnet models in US West (Oregon). | September 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/monitoring-eventbridge.html) | You can now monitor status changes in batch inference jobs using Amazon EventBridge. | September 18, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference-create.html) | You can now submit files from an S3 bucket owned by another account to a batch inference job. | September 16, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-vpc.html) | You can now use a VPC when submitting a batch inference job. | September 16, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) | You can now use an inference profile when generating responses based on results queried from a knowledge base and when parsing a data source. | September 11, 2024 | 
| [Updated content](#doc-history) | Updated topic titles and reorganized content to improve readability. If you'd like to provide feedback on these changes, use this [Provide feedback link](https://docs.aws.amazon.com/bedrock/latest/userguide/doc-history.html). | September 4, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Stable Image Ultra, Stable Diffusion 3 Large, and Stable Image Core models with Amazon Bedrock. | September 4, 2024 | 
| [Updated managed policy](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-AmazonBedrockReadOnly) | Inference profile read-only permissions were added to the AmazonBedrockReadOnly AWS-managed policy. | August 27, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) | You can now use cross-Region inference using inference profiles to increase throughput. | August 27, 2024 | 
| [New feature](https://docs.aws.amazon.com//bedrock/latest/userguide/agents-userconfirmation.html) | You can now request confirmation from your application users before invoking the Amazon Bedrock Agent action group function. | August 26, 2024 | 
| [Updated managed policy](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-AmazonBedrockReadOnly) | Read-only permissions for Batch inference (model invocation job), Amazon Bedrock Guardrails, and Amazon Bedrock Model evaluation were added to the AmazonBedrockReadOnly AWS-managed policy. | August 21, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference.html) | Asynchronous model invocation with multiple prompts with batch inference is now generally available. | August 21, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference.html) | You can now run model inference on multiple prompts asynchronously using batch inference. | August 16, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Amazon Titan Image Generator G1 V2 with Amazon Bedrock. | August 6, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Meta Llama 3 Instruct models 8B and 70B in AWS Region AWS GovCloud (US-West). | August 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/copy-model.html) | You can now copy custom models into other Regions in Amazon Bedrock. | August 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/share-model.html) | You can now share custom models with other accounts in Amazon Bedrock. | August 1, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Mistral AI Mistral Large 2 (24.07) model with Amazon Bedrock. | July 24, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Meta Llama 3.1 Instruct models with Amazon Bedrock. | July 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/br-studio.html) | You can now use Prompt management and Amazon Bedrock Flows with Amazon Bedrock Studio. | July 22, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/flows.html) | You can now string together different Amazon Bedrock resources into a workflow for end-to-end solutions. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management.html) | You can now create and save prompts to reuse in different workflows. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-session-state.html#session-state-kb) | You can now modify query configurations during runtime for knowledge bases that are attached to an agent. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-chunking-parsing.html) | Amazon Bedrock now offers [semantic and hierarchical chunking, and advanced parsing](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-chunking-parsing.html) of more than standard text. You can also use Lambda function for custom data transformations. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html) | Amazon Bedrock now offers [query decomposition](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html) to break down complex queries into smaller, more manageable sub-queries. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/data-source-connectors.html) | You can now [connect to and crawl your data](https://docs.aws.amazon.com/bedrock/latest/userguide/data-source-connectors.html) stored in Confluence, Salesforce, and SharePoint for your knowledge base. You can also connect to and crawl web URLs. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-code-interpretation.html) | You can now use code interpretation in Amazon Bedrock to generate, run, and troubleshoot code in a secure test environment. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-memory.html) | You can now use memory for your agents to retain conversational context across multiple sessions. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-use-independent-api.html) | You can now use an independent API to call your guardrails in Amazon Bedrock. | July 10, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-contextual-grounding-check.html) | You can now use contextual grounding checks with guardrails. | July 10, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-supported.html) | Amazon Bedrock Agents is now supported in Canada (Central) (ca-central-1), Europe (London) (eu-west-2), and South America (São Paulo) (sa-east-1). | June 28, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use AI21 Jamba-Instruct with Amazon Bedrock. | June 25, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-supported.html) | Amazon Bedrock Guardrails is now supported in Canada (Central) (ca-central-1), Europe (London) (eu-west-2), and South America (São Paulo) (sa-east-1). | June 21, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/playgrounds.html#chat-playground) | You can now include documents in the [chat playground](https://docs.aws.amazon.com/bedrock/latest/userguide/playgrounds.html#chat-playground) or while [using the Conversation API](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html). | June 21, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Claude 3.5 Sonnet with Amazon Bedrock. | June 20, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-embed.html) | Cohere Embed V3 models now support int8 and binary embedding types in the response. | June 20, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-use-converse-api.html) | You can now use guardrails with the Converse API. | June 18, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html) | Amazon Bedrock is now available in Canada (Central) (ca-central-1), Europe (London) (eu-west-2), and South America (São Paulo) (sa-east-1). For information on endpoints, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html). | June 13, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/trace-events.html) | You can now view information in the trace about whether agent action group results were sent to be handled by a Lambda function or whether control was returned to the agent developer. | June 13, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Claude 3 Opus with Amazon Bedrock. | June 7, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html) | You can now use the Converse API to create conversational applications. | May 30, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use.html) | You can now use tools with Amazon Bedrock models. | May 30, 2024 | 
| [More model support for embedding data sources in Amazon Bedrock Knowledge Bases.](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-supported.html) | You can now use Amazon Titan Text Embeddings V2 model to embed your data sources in Amazon Bedrock Knowledge Bases. | May 30, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Mistral Small with Amazon Bedrock. | May 24, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-create.html) | You can now use guardrails with your Agent in Amazon Bedrock. | May 20, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-model-params.html) | You can now modify inference parameters when generating responses from knowledge base retrieval. | May 9, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-models.html) | You can now use Amazon Titan Text Premier model with Amazon Bedrock. | May 7, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/br-studio.html) | Preview release of Amazon Bedrock Studio.  | May 7, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-alias-manage.html) | You can now associate a Provisioned Throughput with an alias of your agent in Amazon Bedrock. | May 2, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html) | Amazon Bedrock is now available in Europe (Ireland) (eu-west-1) and Asia Pacific (Mumbai) (ap-south-1). For information on endpoints, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html).  | May 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup.html) | You can now select MongoDB Atlas as a vector index source in Amazon Bedrock Knowledge Bases. | May 1, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html) | You can now use Titan Embeddings Text V2 model with Amazon Bedrock. | April 30, 2024 | 
| [More model support for Provisioned Throughput](https://docs.aws.amazon.com/bedrock/latest/userguide/pt-supported.html) | You can now purchase Provisioned Throughput for AI21 Labs Jurassic-2 Ultra. | April 30, 2024 | 
| [New models](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Cohere Command R and Cohere Command R\$1 models with Amazon Bedrock. | April 29, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-import-model.html) | You can now import a custom model into Amazon Bedrock. | April 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-returncontrol.html) | In Amazon Bedrock Agents, you can now return the information that an agent elicits from a user in the [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html) response, rather than sending it to a Lambda function. | April 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-action-function.html) | In Amazon Bedrock Agents, you can now define an action group by the parameters that it requires from the user. | April 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-erag.html) | You can now chat with your document with Amazon Bedrock. | April 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-create.html) | You can now select from multiple data sources in Amazon Bedrock Knowledge Bases. | April 23, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html) | You can now use Amazon Bedrock Guardrails to implement safeguards to block harmful content in model inputs and responses based on your use cases. | April 23, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude 3 Opus with Amazon Bedrock. | April 16, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html) | Amazon Bedrock is now available in Asia Pacific (Sydney) (ap-southeast-2). For information on endpoints, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html).  | April 9, 2024 | 
| [CloudFormation support for Amazon Bedrock Agents and Amazon Bedrock Knowledge Bases](https://docs.aws.amazon.com/bedrock/latest/userguide/creating-resources-with-cloudformation.html) | You can now set up and manage your Amazon Bedrock Agents and Amazon Bedrock Knowledge Bases resources with CloudFormation. | April 5, 2024 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html) | Amazon Bedrock is now available in Europe (Paris) (eu-west-3). For information on endpoints, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html).  | April 4, 2024 | 
| [More model support for querying knowledge bases in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-supported.html) | You can now use Anthropic Claude 3 Haiku for knowledge base response generation. | April 4, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Mistral Large with Amazon Bedrock. | April 3, 2024 | 
| [More model support for querying knowledge bases in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-supported.html) | You can now use Anthropic Claude 3 Haiku for knowledge base response generation. | April 3, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/pt-supported.html) | You can now purchase Provisioned Throughput for base models with no commitment. | March 29, 2024 | 
| [More model support for Provisioned Throughput](https://docs.aws.amazon.com/bedrock/latest/userguide/pt-supported.html) | You can now purchase Provisioned Throughput for Anthropic Claude 3 Sonnet, Anthropic Claude 3 Haiku, Cohere Embed English, and Cohere Embed Multilingual. | March 29, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-create.html#kb-create-security-network) | You can now create a network access policy in Amazon OpenSearch Serverless to allow your Amazon Bedrock knowledge base to access a private OpenSearch Serverless vector search collection configured with a VPC endpoint. | March 28, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-ds.html#kb-ds-metadata) | You can now include metadata for your source documents in Amazon Bedrock Knowledge Bases and [filter on the metadata during knowledge base query](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html#kb-test-config-filters). | March 27, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html) | You can now use a prompt template to customize the prompt sent to a model when you query a knowledge base and generate responses. | March 26, 2024 | 
| [More model support for querying knowledge bases in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-supported.html) | You can now use Anthropic Claude 3 Sonnet for knowledge base response generation. | March 25, 2024 | 
| [Decreased latency](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-optimize-performance.html) | You can now optimize on latency for simpler use cases in which agents have a single knowledge base. | March 20, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude 3 Haiku with Amazon Bedrock. | March 13, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Anthropic Claude 3 Sonnet with Amazon Bedrock. | March 4, 2024 | 
| [New model](https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html) | You can now use Mistral AI models with Amazon Bedrock. | March 1, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-test.html) | You can now customize the search strategy in Knowledge Base for Amazon OpenSearch Serverless vector stores that contain a filterable text field. | February 28, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-image-models.html) | You can now detect images with a watermark from Amazon Bedrock Titan Image Generator. | February 14, 2024 | 
| [Updated AWS PrivateLink support](https://docs.aws.amazon.com/bedrock/latest/userguide/usingVPC.html) | You can now use AWS PrivateLink to create interface VPC endpoints for the [Amazon Bedrock Agents Build-time service](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_Operations_Agents_for_Amazon_Bedrock.html). | February 9, 2024 | 
| [IAM role update](https://docs.aws.amazon.com/bedrock/latest/userguide/kb-permissions.html) | You can now use the same service role across knowledge bases and use roles without a predefined prefix. | February 9, 2024 | 
| [Model in legacy status](https://docs.aws.amazon.com/bedrock/latest/userguide/model-lifecycle.html) | Stable Diffusion XL v0.8 is now in legacy status. Migrate to Stable Diffusion XL v1.x before April 30, 2024. | February 2, 2024 | 
| [Code examples chapter added](https://docs.aws.amazon.com/bedrock/latest/userguide/service_code_examples.html) | The Amazon Bedrock guide now includes code examples across a variety of Amazon Bedrock actions and scenarios. | January 25, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-create.html) | Amazon Bedrock Knowledge Bases now offers you a choice between a production and non-production account when you choose to quick create an Amazon OpenSearch Serverless vector store in the console. | January 24, 2024 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/trace-events.html) | Amazon Bedrock Agents now lets you view traces in real-time when you use the test window in the console. | January 18, 2024 | 
| [More model support for embedding data sources in Amazon Bedrock Knowledge Bases](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-supported.html) | Amazon Bedrock Knowledge Bases now supports using the Cohere Embed English and Cohere Embed Multilingual to embed your data sources. | January 17, 2024 | 
| [More model support for Amazon Bedrock Agents and querying knowledge bases in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-supported.html) | Amazon Bedrock Agents and Amazon Bedrock Knowledge Bases response generation now support Anthropic Claude 2.1. | December 27, 2023 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html#bedrock-regions) | Amazon Bedrock is now available in AWS GovCloud (US-West) (us-gov-west-1). For information on endpoints, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html).  | December 21, 2023 | 
| [New vector store support](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup-rds.html) | You can now create a knowledge base in an Amazon Aurora database cluster. For more information, see [Create a vector store in Amazon Aurora](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup-rds.html). | December 21, 2023 | 
| [New managed policies](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam-awsmanpol.html) | Amazon Bedrock has added `AmazonBedrockFullAccess` to give users permission to create, read, update, and delete resources, and `AmazonBedrockReadOnly` to give users read-only permissions for all actions. | December 12, 2023 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-evaluation.html) | Amazon Bedrock now supports creating model evaluation jobs using automatic metrics or human workers. | November 29, 2023 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/model-lifecycle.html) | You can now monitor and customize your [ model versions](https://docs.aws.amazon.com/bedrock/latest/userguide/model-lifecycle.html). | November 29, 2023 | 
| [New Titan models](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-models.html) | New models from Titan include Amazon Titan Image Generator G1 V1 and Amazon Titan Multimodal Embeddings G1. For more information, see [Titan Models](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-models.html). | November 29, 2023 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models.html) | With Continued Pre-training you can teach a model new domain knowledge. For more information, see [Custom Models](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models-reference.html). | November 28, 2023 | 
| [New feature](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-api-query.html) | You can now query knowledge bases through the [Retrieve](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_agent-runtime_Retrieve.html) and [RetrieveAndGenerate](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html) APIs. For more information, see [Query a knowledge base](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-api-query.html). | November 28, 2023 | 
| [General release](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base.html) | General release of the Amazon Bedrock Knowledge Bases service. For more information, see [Amazon Bedrock Knowledge Bases](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base.html). | November 28, 2023 | 
| [General release](https://docs.aws.amazon.com/bedrock/latest/userguide/agents.html) | General release of the Amazon Bedrock Agents service. For more information, see [Amazon Bedrock Agents](https://docs.aws.amazon.com/bedrock/latest/userguide/agents.html). | November 28, 2023 | 
| [Customize more models](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models.html) | You can now customize models from Cohere and Meta. For more information, see [Custom Models](https://docs.aws.amazon.com/bedrock/latest/userguide/custom-models-reference.html). | November 28, 2023 | 
| [New model releases](#doc-history) | Updated documentation to cover new Meta and Cohere models. For more information, see [Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html). | November 13, 2023 | 
| [Documentation localization](#doc-history) | Amazon Bedrock documentation is now available in [Japanese](https://docs.aws.amazon.com/ja_jp/bedrock/latest/userguide/what-is-bedrock.html) and [German](https://docs.aws.amazon.com/de_de/bedrock/latest/userguide/what-is-bedrock.html).  | October 20, 2023 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html#bedrock-regions) | Amazon Bedrock is now available in Europe (Frankfurt) (eu-central-1). For information on endpoints, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html).  | October 19, 2023 | 
| [Region expansion](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html#bedrock-regions) | Amazon Bedrock is now available in Asia Pacific (Tokyo) (ap-northeast-1). For information on endpoints, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html).  | October 3, 2023 | 
| [Gated general release](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html) | Gated general release of the Amazon Bedrock service. For more information, see [Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html).  | September 28, 2023 | 

# Improve the relevance of query responses with a reranker model in Amazon Bedrock
<a name="rerank"></a>

Amazon Bedrock provides access to reranker models that you can use when querying to improve the relevance of the retrieved results. A reranker model calculates the relevance of chunks to a query and reorders the results based on the scores that it calculates. By using a reranker model, you can return responses that are better suited to answering the query. Or, you can include the results in a prompt when running model inference to generate more pertinent and accurate responses. With a reranker model, you can retrieve fewer, but more relevant, results. By feeding these results to the foundation model that you use to generate a response, you can also decrease cost and latency.

Reranker models are trained to identify relevance signals based on a query and then use those signals to rank documents. Because of this, the models can provide more relevant, more accurate results.

**Note**  
You can use reranking for only textual data.

For information about pricing for reranking models, see [Amazon Bedrock Pricing](https://aws.amazon.com/bedrock/pricing/).

Reranking requires the following input, at the minimum:
+ A reranker model that takes a user query and assesses the relevance of the data sources that it can access.
+ The user query.
+ A list of documents that the reranker must reorder according to their relevance to the query.

You can use reranker models in Amazon Bedrock in the following ways:
+ Call the [Rerank](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Rerank.html) operation directly through the Amazon Bedrock API. The `Rerank` operation sends the query, documents, and any additional configurations as input to a reranker model. The model then reranks the documents by relevance to the query and returns the documents in the response.
+ If you're using [Amazon Bedrock Knowledge Bases](knowledge-base.md) for building your Retrieval Augmented Generation (RAG) application, use a reranker model while calling the [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html) or [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RetrieveAndGenerate.html) operation or when querying your knowledge base in the AWS Management Console. The results from reranking override the default ranking that Amazon Bedrock Knowledge Bases determines.

**Topics**
+ [Supported Regions/models](rerank-supported.md)
+ [Permissions](rerank-prereq.md)
+ [Use a reranker model](rerank-use.md)

# Supported Regions and models for reranking in Amazon Bedrock
<a name="rerank-supported"></a>

The following list provides links to general information about Regional and model support in Amazon Bedrock:
+ For a list of Region codes and endpoints supported in Amazon Bedrock, see [Amazon Bedrock endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bedrock_region).
+ For a list of Amazon Bedrock model IDs to use when calling Amazon Bedrock API operations, see [Supported foundation models in Amazon Bedrock](models-supported.md).

The following table shows the reranker models you can use and the Regions in which they are supported:

**Note**  
The Amazon Rerank 1.0 model is not supported in the US East (N. Virginia) AWS Region. You can only use the Cohere Rerank 3.5 model in this Region.

The following table shows model support for reranking:


| Provider | Model | Model ID | Single-region model support | 
| --- | --- | --- | --- | 
| Amazon | Rerank 1.0 | amazon.rerank-v1:0 |  ap-northeast-1 ca-central-1 eu-central-1 us-west-2  | 
| Cohere | Rerank 3.5 | cohere.rerank-v3-5:0 |  ap-northeast-1 ca-central-1 eu-central-1 us-east-1 us-west-2  | 

For more information about reranking with Cohere models and their inference parameters, see [Rerank](https://docs.cohere.com/reference/rerank) on the Cohere documentation website.

# Permissions for reranking in Amazon Bedrock
<a name="rerank-prereq"></a>

A user requires the following permissions to use reranking:
+ Access to the reranking models that they plan to use. For more information, see [Request access to models](model-access.md). For third-party models (such as Cohere Rerank), your IAM role also needs `aws-marketplace:ViewSubscriptions` and `aws-marketplace:Subscribe` permissions. For more information, see [Use product ID condition keys to control access](model-access-product-ids.md).
+ Permissions for their role and, if they plan to use reranking in a [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html) workflow, permissions for the Amazon Bedrock Knowledge Bases service role that has a [trust relationship](kb-permissions.md#kb-permissions-trust) with their role.
**Tip**  
To configure the required permissions quickly, you can do the following:  
Attach the [AmazonBedrockFullAccess](security-iam-awsmanpol.md#security-iam-awsmanpol-AmazonBedrockFullAccess) AWS managed policy to the user role. For more information about attaching a policy to an IAM role, see [Adding and removing IAM identity permissions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html).
Use the Amazon Bedrock console to create an Amazon Bedrock Knowledge Bases service role when [creating a knowledge base](knowledge-base-create.md). If you already have an Amazon Bedrock Knowledge Bases service role that the console created for you, you can use the console to update it when [retrieving sources](kb-test-retrieve.md) in the console.
**Important**  
When you use reranking in a `Retrieve` workflow with an Amazon Bedrock Knowledge Bases service role, note the following:  
If you manually edit the AWS Identity and Access Management (IAM) policy that Amazon Bedrock created for your knowledge base service role, then you might encounter errors when trying to update the permissions in the AWS Management Console. To resolve this issue, in the IAM console, delete the policy version that you created manually. Then, refresh the reranker page in the Amazon Bedrock console and retry.
If you use a custom role, then Amazon Bedrock can't update the knowledge base service role on your behalf. Verify that the permissions are properly configured for the service role.

  For a summary of use cases and the permissions needed for them, refer to the following table:  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/bedrock/latest/userguide/rerank-prereq.html)

For example permissions policies that you can attach to an IAM role, expand the section that corresponds to your use case:

## Permissions policy for using a reranking model independently
<a name="rerank-permissions-rerank"></a>

To use [Rerank](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Rerank.html) directly with a list of sources, the user role needs permissions to use both the `bedrock:Rerank` and `bedrock:InvokeModel` actions. Similarly, to prevent usage of a reranking model, you must deny permissions for both actions. To allow the user role to use a reranking model independently, you can attach the following policy to the role:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RerankSid",
            "Effect": "Allow",
            "Action": [
                "bedrock:Rerank"
            ],
            "Resource": "*"
        },
        {
            "Sid": "InvokeModelSid",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/model-id"
            ]
        }
    ]
}
```

------

In the preceding policy, for the `bedrock:InvokeModel` action, you scope the permissions to the models that you want to allow the role to use for reranking. To allow access to all models, use a wildcard (*\$1*) in the `Resource` field.

## Permissions policies for using a reranking model in a Retrieve workflow
<a name="rerank-permissions-retrieve"></a>

To use reranking while retrieving data from a knowledge base, you must set up the following permissions:

**For the user role**

The user role needs permissions to use the `bedrock:Retrieve` action. To allow the user role to retrieve data from a knowledge base, you can attach the following policy to the role:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RetrieveSid",
            "Effect": "Allow",
            "Action": [
                "bedrock:Retrieve"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1:123456789012:knowledge-base/KnowledgeBaseId"
            ]
        }
    ]
}
```

------

In the preceding policy, for the `bedrock:Retrieve` action, you scope the permissions to the knowledge bases from which you want to allow the role to retrieve information. To allow access to all knowledge bases, you can use a wildcard (*\$1*) in the `Resource` field.

**For the service role**

The [Amazon Bedrock Knowledge Bases service role](kb-permissions.md) that the user uses needs permissions to use the `bedrock:Rerank` and `bedrock:InvokeModel` actions. You can use the Amazon Bedrock console to configure permissions for your service role automatically when you choose a reranking model when you [configure knowledge base retrieval](kb-test-retrieve.md). Otherwise, to allow the service role to rerank sources during retrieval, you can attach the following policy:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RerankSid",
            "Effect": "Allow",
            "Action": [
                "bedrock:Rerank"
            ],
            "Resource": "*"
        },
        {
            "Sid": "InvokeModelSid",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": "arn:aws:bedrock:us-east-1::foundation-model/RerankModelId"
        }
    ]
}
```

------

In the preceding policy, for the `bedrock:InvokeModel` action, you scope the permissions to the models that you want to allow the role to use for reranking. To allow access to all models, you can use a wildcard (\$1) in the `Resource` field.

## Permissions policy for using a reranking model in a RetrieveAndGenerate workflow
<a name="rerank-permissions-retrieve-and-generate"></a>

To use a reranker model when retrieving data from a knowledge base and subsequently generating responses based on the retrieved results, the user role needs permissions to use the `bedrock:RetrieveAndGenerate`, `bedrock:Rerank`, and `bedrock:InvokeModel` actions. To allow reranking of sources during retrieval, and to allow generation of responses based on the results, you can attach the following policy to the user role:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RerankRetrieveAndGenerateSid",
            "Effect": "Allow",
            "Action": [
                "bedrock:Rerank",
                "bedrock:RetrieveAndGenerate"
            ],
            "Resource": "*"
        },
        {
            "Sid": "InvokeModelSid",
            "Effect": "Allow",
            "Action": [
                "bedrock:InvokeModel"
            ],
            "Resource": [
                "arn:aws:bedrock:us-east-1::foundation-model/RerankModelId}",
                "arn:aws:bedrock:us-east-1::foundation-model/GenerationModelId}"
            ]
        }
    ]
}
```

------

In the preceding policy, for the `bedrock:InvokeModel` operation, you scope the permissions to the models that you want to allow the role to use for reranking, and to the models that you want to allow the role to use for generating responses. To allow access to all models, you can use a wildcard (*\$1*) in the `Resource` field.

To further restrict permissions, you can omit actions, or you can specify resources and condition keys by which to filter permissions. For more information about actions, resources, and condition keys, see the following topics in the *Service Authorization Reference*:
+ [Actions defined by Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-actions-as-permissions) – Learn about actions, the resource types that you can scope them to in the `Resource` field, and the condition keys that you can filter permissions on in the `Condition` field.
+ [Resource types defined by Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-resources-for-iam-policies) – Learn about the resource types in Amazon Bedrock.
+ [Condition keys for Amazon Bedrock](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonbedrock.html#amazonbedrock-policy-keys) – Learn about the condition keys in Amazon Bedrock.

# Use a reranker model in Amazon Bedrock
<a name="rerank-use"></a>

You can use a reranker model directly or while retrieving results during knowledge base query. Choose the tab for your preferred method, and then follow the steps:

------
#### [ Console ]

You can't use a reranker model directly in the AWS Management Console, but you can use a reranker model when querying your knowledge base by doing the following:

1. When you query a knowledge base, open up the **Configurations** pane by choosing the ![\[Three horizontal sliders with adjustable circular controls for settings or parameters.\]](http://docs.aws.amazon.com/bedrock/latest/userguide/images/icons/configurations.png) icon.

1. Expand the **Reranking** section.

1. Choose **Select model** and select a reranker model.

1. If your Amazon Bedrock Knowledge Bases service role is missing [permissions to use the reranker model](rerank-prereq.md), select **Update service role** to modify the role with the proper permissions.

1. (Optional) In the **Additional Reranking options** section, modify any options that you need to.

1. Enter a prompt and select **Run**. The response is the result after applying the reranker model.

For more detailed instructions about carrying out knowledge base query, see [Query a knowledge base and retrieve data](kb-test-retrieve.md) and [Query a knowledge base and generate responses based off the retrieved data](kb-test-retrieve-generate.md).

------
#### [ API ]

For instructions on using a reranker model during knowledge base query, see [Query a knowledge base and retrieve data](kb-test-retrieve.md) and [Query a knowledge base and generate responses based off the retrieved data](kb-test-retrieve-generate.md).

To use a reranker model directly with the Amazon Bedrock API, send a [Rerank](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Rerank.html) request with an [Agents for Amazon Bedrock runtime endpoint](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-rt).

The following fields are required:


****  

| Field | Basic description | 
| --- | --- | 
| queries | An array of one [RerankQuery](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RerankQuery.html) object. Specify TEXT as the type and include the query in the textQuery field. | 
| sources | An array of [RerankSource](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RerankSource.html) objects to submit to the reranking model. For each RerankSource, specify INLINE as the type and include a [RerankDocument](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RerankDocument.html) object in the inlineDocumentSource field. See below for details about RerankDocument. | 
| rerankingConfiguration | Includes the Amazon Resource Name (ARN) of the reranking model to use, and the number of results to return after reranking, and, optionally, inference configurations for the model. You specify additional model configurations as key-value pairs. For more information, see [Rerank](https://docs.cohere.com/reference/rerank) on the Cohere documentation website. | 

The following fields are optional:


****  

| Field | Use case | 
| --- | --- | 
| nextToken | A token returned in a previous response that you can include to provide the next batch of results. | 

The format of the `RerankSource` object that you include depends on the format of the document. To see the format for different `RerankSource` types, choose the tab that corresponds to the format of the document:

------
#### [ String ]

If the document is a string, then specify the value of the `type` field of the [RerankDocument](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RerankDocument.html) object as `TEXT` and include the document in the `text` field. For example:

```
{
    "inlineDocumentSource": {
        "textDocument": {
            "text": "string"
        },
        "type": "TEXT"
    },
    "type": "INLINE"
}
```

------
#### [ JSON object ]

If the document is a JSON object, then specify the value of the `type` field in the [RerankDocument](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RerankDocument.html) object as `JSON` and include the document in the `jsonDocument` field. For example:

```
{
    "inlineDocumentSource": {
        "jsonDocument": JSON value,
        "type": "JSON"
    },
    "type": "INLINE"
}
```

------

The response to your `Rerank` request returns a list of [RerankResult](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_RerankResult.html) objects in the `results` field. Each object contains the following fields:
+ `document` – Includes information about the document that you submitted.
+ `relevanceScore` – A relevance score for the document, assigned by the reranking model.
+ `index` – Indicates the document's ranking relative to the other documents in the list. The lower the score, the higher the ranking.

If there are too many results to display, then the response returns a value in the `nextToken` field. In this case, to see the next batch of results, include that token in a subsequent request.

------

# Overview of Amazon Titan models
<a name="titan-models"></a>

 Amazon Titan foundation models (FMs) are a family of FMs pretrained by AWS on large datasets, making them powerful, general-purpose models built to support a variety of use cases. Use them as-is or privately customize them with your own data.

Amazon Titan supports the following models for Amazon Bedrock.
+ **Amazon Titan Text Embeddings V2**
+ **Amazon Titan Multimodal Embeddings G1**
+ **Amazon Titan Image Generator G1 v2**

**Topics**
+ [Amazon Titan Text Embeddings models](titan-embedding-models.md)
+ [Amazon Titan Multimodal Embeddings G1 model](titan-multiemb-models.md)
+ [Amazon Titan Image Generator G1 model](titan-image-models.md)

# Amazon Titan Text Embeddings models
<a name="titan-embedding-models"></a>

Amazon Titan Embeddings models include Amazon Titan Text Embeddings V2 and Titan Text Embeddings G1 model.

**Note**  
Embedding models on Amazon Bedrock are throttled by Requests Per Minute (RPM), not Tokens Per Minute (TPM). When planning capacity or requesting quota increases for embedding models, use the RPM quota. For more information, see [Quotas for Amazon Bedrock](quotas.md).

Text embeddings represent meaningful vector representations of unstructured text such as documents, paragraphs, and sentences. You input a body of text and the output is a (1 x n) vector. You can use embedding vectors for a wide variety of applications.

The Amazon Titan Text Embedding v2 model (`amazon.titan-embed-text-v2:0`) can intake up to 8,192 tokens or 50,000 characters and outputs a vector of 1,024 dimensions. The model is optimized for text retrieval tasks, but can also be used for additional tasks, such as semantic similarity and clustering.

Amazon Titan Embeddings models generate meaningful semantic representation of documents, paragraphs and sentences. Amazon Titan Text Embeddings takes as input a body of text and generates a (1 x n) vector. Amazon Titan Text Embeddings is offered via latency-optimized endpoint invocation for generating vectors at low latency (recommended during the retrieval step) as well as throughput optimized batch jobs for faster indexing. The actual similarity computation and retrieval are performed by your vector database, not by the embedding model. Amazon Titan Text Embeddings v2 supports long documents, however for retrieval tasks, it is recommended to segment documents into logical segments, such as paragraphs or sections.

**Note**  
Amazon Titan Text Embeddings v2 model and Titan Text Embeddings v1 model do not support inference parameters such as `maxTokenCount` or `topP`.

**Amazon Titan Text Embeddings V2 model**
+ **Model ID** – `amazon.titan-embed-text-v2:0`
+ **Max input text tokens** – 8,192
+ **Max input text characters** – 50,000
+ **Languages** – English (100\$1 languages in preview)
+ **Output vector size** – 1,024 (default), 512, 256
+ **Inference types** – On-Demand, Provisioned Throughput
+ **Supported use cases** – RAG, document search, reranking, classification, etc.

**Note**  
Titan Text Embeddings V2 takes as input a non-empty string with up to 8,192 tokens or 50,000 characters. The characters to token ratio in English is 4.7 characters per token, on average. While Titan Text Embeddings V1 and Titan Text Embeddings V2 are able to accommodate up to 8,192 tokens, it is recommended to segment documents into logical segments (such as paragraphs or sections).

The Amazon Titan Embedding Text v2 model is optimized for English, with multilingual support for the following languages. Cross-language queries (such as providing a knowledge base in Korean and querying it in German) will return sub-optimal results.
+ Afrikaans
+ Albanian
+ Amharic
+ Arabic
+ Armenian
+ Assamese
+ Azerbaijani
+ Bashkir
+ Basque
+ Belarusian
+ Bengali
+ Bosnian
+ Breton
+ Bulgarian
+ Burmese
+ Catalan
+ Cebuano
+ Chinese
+ Corsican
+ Croatian
+ Czech
+ Danish
+ Dhivehi
+ Dutch
+ English
+ Esperanto
+ Estonian
+ Faroese
+ Finnish
+ French
+ Galician
+ Georgian
+ German
+ Gujarati
+ Haitian
+ Hausa
+ Hebrew
+ Hindi
+ Hungarian
+ Icelandic
+ Indonesian
+ Irish
+ Italian
+ Japanese
+ Javanese
+ Kannada
+ Kazakh
+ Khmer
+ Kinyarwanda
+ Kirghiz
+ Korean
+ Kurdish
+ Lao
+ Latin
+ Latvian
+ Lithuanian
+ Luxembourgish
+ Macedonian
+ Malagasy
+ Malay
+ Malayalam
+ Maltese
+ Maori
+ Marathi
+ Modern Greek
+ Mongolian
+ Nepali
+ Norwegian
+ Norwegian Nynorsk
+ Occitan
+ Oriya
+ Panjabi
+ Persian
+ Polish
+ Portuguese
+ Pushto
+ Romanian
+ Romansh
+ Russian
+ Sanskrit
+ Scottish Gaelic
+ Serbian
+ Sindhi
+ Sinhala
+ Slovak
+ Slovenian
+ Somali
+ Spanish
+ Sundanese
+ Swahili
+ Swedish
+ Tagalog
+ Tajik
+ Tamil
+ Tatar
+ Telugu
+ Thai
+ Tibetan
+ Turkish
+ Turkmen
+ Uighur
+ Ukrainian
+ Urdu
+ Uzbek
+ Vietnamese
+ Waray
+ Welsh
+ Western Frisian
+ Xhosa
+ Yiddish
+ Yoruba
+ Zulu

# Amazon Titan Multimodal Embeddings G1 model
<a name="titan-multiemb-models"></a>

Amazon Titan Foundation Models are pre-trained on large datasets, making them powerful, general-purpose models. Use them as-is, or customize them by fine tuning the models with your own data for a particular task without annotating large volumes of data.

There are three types of Titan models: embeddings, text generation, and image generation.

There are two Titan Multimodal Embeddings G1 models. The Titan Multimodal Embeddings G1 model translates text inputs (words, phrases or possibly large units of text) into numerical representations (known as embeddings) that contain the semantic meaning of the text. While this model will not generate text, it is useful for applications like personalization and search. By comparing embeddings, the model will produce more relevant and contextual responses than word matching. The Multimodal Embeddings G1 model is used for use cases like searching images by text, by image for similarity, or by a combination of text and image. It translates the input image or text into an embedding that contain the semantic meaning of both the image and text in the same semantic space.

Titan Text models are generative LLMs for tasks such as summarization, text generation, classification, open-ended QnA, and information extraction. They are also trained on many different programming languages, as well as rich text format like tables, JSON, and .csv files, among other formats.

**Amazon Titan Multimodal Embeddings model G1**
+ **Model ID** – `amazon.titan-embed-image-v1`
+ **Max input text tokens** – 256
+ **Languages** – English 
+ **Max input image size** – 25 MB
+ **Output vector size** – 1,024 (default), 384, 256
+ **Inference types** – On-Demand, Provisioned Throughput
+ **Supported use cases** – Search, recommendation, and personalization.

Titan Text Embeddings V1 takes as input a non-empty string with up to 8,192 tokens and returns a 1,024 dimensional embedding. The characters to token ratio in English is 4.7 char/token, on average. Note on RAG uses cases: While Titan Text Embeddings V2 is able to accommodate up to 8,192 tokens, we recommend to segment documents into logical segments (such as paragraphs or sections). 

## Embedding length
<a name="titanmm-embedding"></a>

Setting a custom embedding length is optional. The embedding default length is 1024 characters which will work for most use cases. The embedding length can be set to 256, 384, or 1024 characters. Larger embedding sizes create more detailed responses, but will also increase the computational time. Shorter embedding lengths are less detailed but will improve the response time. 

```
    # EmbeddingConfig Shape
    {
     'outputEmbeddingLength': int // Optional, One of: [256, 384, 1024], default: 1024
    }
    
    # Updated API Payload Example
    body = json.dumps({
     "inputText": "hi",
     "inputImage": image_string,
     "embeddingConfig": { 
     "outputEmbeddingLength": 256
     }
    })
```

## Finetuning
<a name="titanmm-finetuning"></a>
+ Input to the Amazon Titan Multimodal Embeddings G1 finetuning is image-text pairs. 
+ Image formats: PNG, JPEG
+ Input image size limit: 25 MB
+ Image dimensions: min: 256 px, max: 4,096 px
+ Max number of tokens in caption: 128
+ Training dataset size range: 1000 - 500,000
+ Validation dataset size range: 8 - 50,000
+ Caption length in characters: 0 - 2,560
+ Maximum total pixels per image: 2048\$12048\$13
+ Aspect ratio (w/h): min: 0.25, max: 4

## Preparing datasets
<a name="titanmm-datasets"></a>

For the training dataset, create a `.jsonl`file with multiple JSON lines. Each JSON line contains both an `image-ref` and `caption` attributes similar to [Sagemaker Augmented Manifest format](https://docs.aws.amazon.com/sagemaker/latest/dg/augmented-manifest.html). A validation dataset is required. Auto-captioning is not currently supported.

```
   {"image-ref": "s3://bucket-1/folder1/0001.png", "caption": "some text"}
   {"image-ref": "s3://bucket-1/folder2/0002.png", "caption": "some text"}
   {"image-ref": "s3://bucket-1/folder1/0003.png", "caption": "some text"}
```

For both the training and validation datasets, you will create `.jsonl`files with multiple JSON lines.

The Amazon S3 paths need to be in the same folders where you have provided permissions for Amazon Bedrock to access the data by attaching an IAM policy to your Amazon Bedrock service role. For more information on granting an IAM policies for training data, see [Grant custom jobs access to your training data](https://docs.aws.amazon.com/bedrock/latest/userguide/security_iam_id-based-policy-examples.html#security_iam_id-based-policy-examples-model-customization).

## Hyperparameters
<a name="titanmm-hyperparameters"></a>

These values can be adjusted for the Multimodal Embeddings model hyperparameters. The default values will work well for most use cases.
+ Learning rate - (min/max learning rate) – default: 5.00E-05, min: 5.00E-08, max: 1
+ Batch size - Effective batch size – default: 576, min: 256, max: 9,216 
+ Max epochs – default: "auto", min: 1, max: 100

# Amazon Titan Image Generator G1 model
<a name="titan-image-models"></a>

Amazon Titan Image Generator G1 is an image generation model that enables users to generate and edit images in versatile ways. Users can create images that match their text-based descriptions by simply inputting natural language prompts. Furthermore, they can upload and edit existing images, including applying text-based prompts without the need for a mask, or editing specific parts of an image using an image mask. The model also supports outpainting, which extends the boundaries of an image, and inpainting, which fills in missing areas. It offers the ability to generate variations of an image based on an optional text prompt, as well as instant customization options that allow users to transfer styles using reference images or combine styles from multiple references, all without requiring any fine-tuning.

Amazon Titan Image Generator G1 v2 adds several advanced capabilities. It allows users to leverage reference images to guide image generation, where the output image aligns with the layout and composition of the reference image while still following the textual prompt. It also includes an automatic background removal feature, which can remove backgrounds from images containing multiple objects without any user input. The model provides precise control over the color palette of generated images, allowing users to preserve a brand's visual identity without the requirement for additional fine-tuning. Additionally, the subject consistency feature enables users to fine-tune the model with reference images to preserve the chosen subject (e.g., pet, shoe or handbag) in generated images. This comprehensive suite of features empowers users to unleash their creative potential and bring their imaginative visions to life.

For more information on Amazon Titan Image Generator G1 model prompt engineering guidelines, see [Amazon Titan Image Generator Prompt Engineering Best Practices](https://d2eo22ngex1n9g.cloudfront.net/Documentation/User+Guides/Titan/Amazon+Titan+Image+Generator+Prompt+Engineering+Guidelines.pdf).

To continue supporting best practices in the responsible use of AI, Titan Foundation Models (FMs) are built to detect and remove harmful content in the data, reject inappropriate content in the user input, and filter the models’ outputs that contain inappropriate content (such as hate speech, profanity, and violence). The Titan Image Generator FM adds an invisible watermark and [C2PA](https://c2pa.org/) metadata to all generated images.

You can use the watermark detection feature in Amazon Bedrock console or call Amazon Bedrock watermark detection API (preview) to check whether an image contains watermark from Titan Image Generator. You can also use sites like [Content Credentials Verify](https://contentcredentials.org/verify) to check if an image was generated by Titan Image Generator.

**Amazon Titan Image Generator v2** overview
+ **Model ID** – `amazon.titan-image-generator-v2:0 `
+ **Max input characters** – 512 char
+ **Max input image size** – 5 MB (only some specific resolutions are supported)
+ **Max image size using in/outpainting, background removal, image conditioning, color palette** – 1,408 x 1,408 px
+ **Max image size using image variation** – 4,096 x 4,096 px
+ **Languages** – English
+ **Output type** – image
+ **Supported image types** – JPEG, JPG, PNG
+ **Inference types** – On-Demand, Provisioned Throughput
+ **Supported use cases** – image generation, image editing, image variations, background removal, color guided content 

## Features
<a name="titanimage-features"></a>
+ Text-to-image (T2I) generation – Input a text prompt and generate a new image as output. The generated image captures the concepts described by the text prompt.
+ Finetuning of a T2I model – Import several images to capture your own style and personalization and then fine tune the core T2I model. The fine-tuned model generates images that follow the style and personalization of a specific user.
+ Image editing options – include: inpainting, outpainting, generating variations, and automatic editing without an image mask.
+ Inpainting – Uses an image and a segmentation mask as input (either from the user or estimated by the model) and reconstructs the region within the mask. Use inpainting to remove masked elements and replace them with background pixels. 
+ Outpainting – Uses an image and a segmentation mask as input (either from the user or estimated by the model) and generates new pixels that seamlessly extend the region. Use precise outpainting to preserve the pixels of the masked image when extending the image to the boundaries. Use default outpainting to extend the pixels of the masked image to the image boundaries based on segmentation settings.
+ Image variation – Uses 1 to 5 images and an optional prompt as input. It generates a new image that preserves the content of the input image(s), but varies its style and background. 
+ Image conditioning – (V2 only) Uses an input reference image to guide image generation. The model generates output image that aligns with the layout and the composition of the reference image, while still following the textual prompt.
+ Subject consistency – (V2 only) Subject consistency allows users to fine-tune the model with reference images to preserve the chosen subject (for example, pet, shoe, or handbag) in generated images.
+ Color guided content – (V2 only) You can provide a list of hex color codes along with a prompt. A range of 1 to 10 hex codes can be provided. The image returned by Titan Image Generator G1 V2 will incorporate the color palette provided by the user.
+ Background removal – (V2 only) Automatically identifies multiple objects in the input image and removes the background. The output image has a transparent background.
+ Content provenance – Use sites like [Content Credentials Verify](https://contentcredentials.org/verify) to check if an image was generated by Titan Image Generator. This should indicate the image was generated unless the metadata has been removed.

**Note**  
if you are using a fine-tuned model, you cannot use inpainting, outpainting or color palette features of the API or the model. 

## Parameters
<a name="titanimage-parameters"></a>

For information on Amazon Amazon Titan Image Generator G1 model inference parameters, see [Amazon Titan Image Generator G1 model inference parameters](model-parameters-titan-image.md).

## Fine-tuning
<a name="titanimage-finetuning"></a>

For more information on fine-tuning the Amazon Titan Image Generator G1 model, see the following pages.
+ [Prepare data for fine-tuning your models](model-customization-prepare.md)
+ [Amazon Titan Image Generator G1 models customization hyperparameters](custom-models-hp.md#cm-hp-titan-image)

**Amazon Titan Image Generator G1 model fine-tuning and pricing**

The model uses the following example formula to calculate the total price per job:

Total Price = Steps \$1 Batch size \$1 Price per image seen

Minimum values (auto):
+ Minimum steps (auto) - 500
+ Minimum batch size - 8
+ Default learning rate - 0.00001
+ Price per image seen - 0.005

**Fine-tuning hyperparameter settings**

**Steps** – The number of times the model is exposed to each batch. There is no default step count set. You must select a number between 10 - 40,000, or a String value of "Auto." 

**Step settings - Auto** – Amazon Bedrock determines a reasonable value based on training information. Select this option to prioritize model performance over training cost. The number of steps is determined automatically. This number will typically be between 1,000 and 8,000 based on your dataset. Job costs are impacted by the number of steps used to expose the model to the data. Refer to the pricing examples section of pricing details to understand how job cost is calculated. (See example table above to see how step count is related to number of images when Auto is selected.) 

**Step settings - Custom** – You can enter the number of steps you want Bedrock to expose your custom model to the training data. This value can be between 10 and 40,000. You can reduce the cost per image produced by the model by using a lower step count value. 

**Batch size** – The number of sample processed before model parameters are updated. This value is between 8 and 192 and is a multiple of 8. 

**Learning rate** – The rate at which model parameters are updated after each batch of training data. This is a float value between 0 and 1. The learning rate is set to 0.00001 by default. 

For more information on the fine-tuning procedure, see [Submit a model customization job.](https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-submit.html)

## Output
<a name="titanimage-output"></a>

The Amazon Titan Image Generator G1 model uses the output image size and quality to determine how an image is priced. The model has two pricing segments based on size: one for 512\$1512 images and another for 1024\$11024 images. Pricing is based on image size height\$1width, less than or equal to 512\$1512 or greater than 512\$1512.

For more information on Amazon Bedrock pricing, see [Amazon Bedrock Pricing.](https://aws.amazon.com/bedrock/pricing/)

## Watermark detection
<a name="titanimage-watermark"></a>

**Note**  
Watermark detection for the Amazon Bedrock console and API is available in public preview release and will only detect a watermark generated from Titan Image Generator G1. This feature is currently only available in the `us-west-2` and `us-east-1` Regions. Watermark detection is a highly accurate detection of the watermark generated by Titan Image Generator G1. Images that are modified from the original image may produce less accurate detection results.

This model adds an invisible watermark to all generated images to reduce the spread of misinformation, assist with copyright protection, and track content usage. Watermark detection is available to help you confirm whether an image was generated by the Titan Image Generator G1 model, which checks for the existence of this watermark. 

**Note**  
Watermark Detection API is in preview and is subject to change. We recommend that you create a virtual environment to use the SDK. Because watermark detection APIs aren't available in the latest SDKs, we recommend that you uninstall the latest version of the SDK from the virtual environment before installing the version with the watermark detection APIs.

You can upload your image to detect if a watermark from Titan Image Generator G1 is present on the image. Use the console to detect a watermark from this model by following the below steps.

**To detect a watermark with Titan Image Generator G1:**

1. Open the Amazon Bedrock console at [Amazon Bedrock console](https://console.aws.amazon.com/bedrock)

1. Select **Overview** from the navigation pane in Amazon Bedrock. Choose the **Build and Test** tab.

1. In the **Safeguards** section, go to **Watermark detection** and choose **View watermark detection**.

1. Select **Upload image** and locate a file that is in JPG or PNG format. The maximum file size allowed is 5 MB.

1. Once uploaded, a thumbnail of image is shown with the name, file size, and the last date modified. Select X to delete or replace image from the **Upload** section.

1. Select **Analyze** to begin watermark detection analysis.

1. The image is previewed under **Results**, and indicates if a watermark is detected with **Watermark detected** below the image and a banner across the image. If no watermark is detected, the text below the image will say **Watermark NOT detected**.

1. To load the next image, select X in the thumbnail of the image in the **Upload** section and choose a new image to analyze.

## Prompt Engineering Guidelines
<a name="titanimage-prompt"></a>

**Mask prompt** – This algorithm classifies pixels into concepts. The user can give a text prompt that will be used to classify the areas of the image to mask, based on the interpretation of the mask prompt. The prompt option can interpret more complex prompts, and encode the mask into the segmentation algorithm.

**Image mask** – You can also use an image mask to set the mask values. The image mask can be combined with prompt input for the mask to improve accuracy. The image mask file must conform to the following parameters:
+ Mask image values must be 0 (black) or 255 (white) for the mask image. The image mask area with the value of 0 will be regenerated with the image from the user prompt and/or input image.
+ The `maskImage` field must be a base64 encoded image string.
+ Mask image must have the same dimensions as the input image (same height and width).
+ Only PNG or JPG files can be used for the input image and the mask image.
+ Mask image must only use black and white pixels values.
+ Mask image can only use the RGB channels (alpha channel not supported).

For more information on Amazon Titan Image Generator prompt engineering, see [Amazon Titan Image Generator G1 models Prompt Engineering Best Practices](https://d2eo22ngex1n9g.cloudfront.net/Documentation/User+Guides/Titan/Amazon+Titan+Image+Generator+Prompt+Engineering+Guidelines.pdf). 

For general prompt engineering guidelines, see [Prompt Engineering Guidelines](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-engineering-guidelines.html).