# Amazon Bedrock

{% hint style="info" %}
**Before you begin**

To use Anthropic models (such as Claude Sonnet or Claude Opus), Amazon Bedrock requires you to submit your use case details before granting access to their models on Bedrock. Please refer to the [Claude Documentation](https://code.claude.com/docs/en/amazon-bedrock) for more information.
{% endhint %}

## Create an Amazon Bedrock access policy

Create an IAM policy that grants permission to call Amazon Bedrock models. This is the only permission required for the extension.

1. Open the **IAM** page in AWS.
2. Go to **Policies**.
3. Click **Create policy**.

   <figure><img src="/files/naMaYAuVcmprZ85UaPVC" alt=""><figcaption></figcaption></figure>
4. Switch to the **JSON** tab and paste the following:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowInvokeModels",
      "Effect": "Allow",
      "Action": [
        "bedrock:InvokeModel",
        "bedrock:InvokeModelWithResponseStream"
      ],
      "Resource": "*"
    }
  ]
}
```

## Set up AWS credentials

Provide AWS credentials that include the policy created above. Choose one of the following options:

<table><thead><tr><th width="118.13671875">Approach</th><th width="281.01171875">Best for</th><th>How credentials work</th></tr></thead><tbody><tr><td><strong>IAM User</strong></td><td>Quick setup, personal use</td><td>Long-lived access keys you generate once</td></tr><tr><td><strong>IAM Role</strong></td><td>Production, shared environments</td><td>Temporary keys</td></tr></tbody></table>

### IAM User

Create a dedicated IAM user and generate permanent access keys.

1. Open the **IAM** page in AWS.
2. Go to **Users**, then click **Create user**.
3. Attach the policy created earlier (either directly or through a group).

   <figure><img src="/files/ILCxU9lYboP86dWviLgM" alt=""><figcaption></figcaption></figure>
4. Go to the **Security credentials** tab.
5. Under **Access keys**, click **Create access key**.
6. Copy the **Access Key ID** and **Secret Access Key**.

### IAM Role *(Recommended)*

IAM roles use temporary credentials that expire automatically, making them more secure for production use. This approach requires the AWS CLI.

1. Open the **IAM** in AWS.
2. Go to **Roles**, then click **Create role**.
3. Attach the policy you created earlier.
4. Generate temporary credentials:
   1. Install and configure the AWS CLI (if you haven't already):
      1. [Install the AWS CLI →](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
      2. [Configure your CLI credentials →](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)
   2. Ensure your CLI credentials have permission to assume the role.
   3. Generate temporary credentials by running the following command. Replace `ACCOUNT_ID` with your 12-digit AWS account ID.

```bash
aws sts assume-role \\
  --role-arn arn:aws:iam::ACCOUNT_ID:role/BedrockRole \\
  --role-session-name bedrock-session
```

You'll get a response like this:

```json
{
  "Credentials": {
    "AccessKeyId": "ASIA...",
    "SecretAccessKey": "...",
    "SessionToken": "...",
    "Expiration": "2026-02-12T12:00:00Z"
  }
}
```

{% hint style="info" %}
**These credentials are temporary.** When they expire (check the `Expiration` timestamp), run the `assume-role` command again and update the extension with the new values.
{% endhint %}

## Start prediction

You should now have the required credentials. Copy the values from the response, enter them into the extension, then click **Predict labels**.

<table data-header-hidden><thead><tr><th width="219.98046875"></th><th></th></tr></thead><tbody><tr><td><strong>Access Key ID</strong></td><td><code>AccessKeyId</code> from the response</td></tr><tr><td><strong>Secret Access Key</strong></td><td><code>SecretAccessKey</code> from the response</td></tr><tr><td><strong>Session Token</strong></td><td><code>SessionToken</code> from the response, empty if you are using IAM User</td></tr></tbody></table>

<figure><img src="/files/7NfL4MGDqmj8wcD44tgf" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datasaur.ai/assisted-labeling/ml-assisted-labeling/llm-assisted-labeling/amazon-bedrock.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
