> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keywordsai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Bedrock

> Use your own AWS credits through Keywords AI

<CardGroup cols={1}>
  <Card title="Get AWS Bedrock credentials" icon="key" href="https://console.aws.amazon.com/iam/home#/security_credentials">
    Get your AWS Bedrock credentials from the AWS Console to start using AWS Bedrock models through Keywords AI.
  </Card>
</CardGroup>

## AWS Bedrock models compatibility

<AccordionGroup>
  <Accordion title="✅ Supported Frameworks">
    * [OpenAI SDK](/integration/development-frameworks/llm_framework/openai/openai-sdk)
    * [LangChain SDK](/integration/development-frameworks/llm_framework/langchain)
    * [Vercel/OpenAI](/integration/development-frameworks/llm_framework/vercel#openai)
    * [Vercel/Google](/integration/development-frameworks/llm_framework/vercel#google)
    * [LlamaIndex SDK](/integration/development-frameworks/llm_framework/llama-index)
    * [Google GenAI](/integration/development-frameworks/llm_framework/google_genai)
    * [Keywords native (Otel)](/get-started/quickstart/gateway)
  </Accordion>

  <Accordion title="❌ Unsupported Frameworks">
    * [Anthropic SDK](/integration/development-frameworks/llm_framework/anthropic)
    * [Vercel/Anthropic](/integration/development-frameworks/llm_framework/vercel#anthropic)
  </Accordion>
</AccordionGroup>

## Add AWS Bedrock API keys

There are 2 ways to add your AWS Bedrock credentials to your requests:

### Via UI

<Steps>
  <Step title="Go to the Providers page">
    Go to [Providers page](https://platform.keywordsai.co/platform/api/providers)

    <Frame>
      <img src="https://keywordsai-static.s3.us-east-1.amazonaws.com/docs/settings/providers.jpg" alt="Providers Page" />
    </Frame>
  </Step>

  <Step title="Add your AWS Bedrock credentials.">
    <img height="200" width="300" src="https://mintcdn.com/keywordsai/-egFtHX1IBbYpy-e/images/providers/bedrock.png?fit=max&auto=format&n=-egFtHX1IBbYpy-e&q=85&s=c476e288bfa8c53caba2570e845ade89" alt="Dashboard Page" data-path="images/providers/bedrock.png" />
  </Step>

  <Step title="(Optional) Choose models you want to use credits">
    You can choose the models you want to use your credits with. Just simply type the model ID from the [Models page](https://platform.keywordsai.co/platform/models) and copy the model id and paste it in the Available models. Press `Enter` to add the model.

    **Leave it empty to apply your credentials for all AWS Bedrock models.**

    <img height="200" width="500" src="https://mintcdn.com/keywordsai/-egFtHX1IBbYpy-e/images/providers/bedrock_model.png?fit=max&auto=format&n=-egFtHX1IBbYpy-e&q=85&s=0ad0f1cb926242f5e62e0590e3e58b3b" alt="Dashboard Page" data-path="images/providers/bedrock_model.png" />
  </Step>
</Steps>

## Add it in code

Add `customer_credentials` parameter in your [request body](/api-endpoints/develop/gateway/chat-completions) to use your own AWS Bedrock credits.

```json theme={"system"}
{
  // Rest of the request body
  "customer_credentials": {
    "bedrock": {
      "aws_access_key_id": "aws_access_key_id",
      "aws_secret_access_key": "aws_secret_access_key",
      "aws_region_name": "aws_region_name",
    }
  }
}
```

## Override credentials for a particular model. (Optional)

One-off credential overrides. Instead of using what is uploaded for each provider, this targets credentials for individual models.

```json theme={"system"}
{
  // Rest of the request body
  "customer_credentials": {
    "bedrock": {
      "aws_access_key_id": "aws_access_key_id",
      "aws_secret_access_key": "aws_secret_access_key",
      "aws_region_name": "aws_region_name",
    }
  },
  "credential_override": {
    "bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0":{ // override for a specific model.
      "aws_access_key_id": "another_aws_access_key_id",
      "aws_secret_access_key": "another_aws_secret_access_key",
      "aws_region_name": "another_aws_region_name",
    }
  }
}
```

## Full request example

<Accordion title="Example">
  <CodeGroup>
    ```python openai_example.py theme={"system"}
    from openai import OpenAI

    client = OpenAI(
        base_url="https://api.keywordsai.co/api/",
        api_key="YOUR_KEYWORDSAI_API_KEY",
    )

    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role":"user", "content":"Tell me a long story"}],
        extra_body={"customer_credentials": {
                      "bedrock": {
                          "aws_access_key_id": "YOUR_BEDROCK_API_KEY",
                          "aws_secret_access_key": "YOUR_BEDROCK_API_BASE_URL",
                          "aws_region_name": "YOUR_BEDROCK_API_VERSION",
                      }
                    }
                  }
    )
    ```

    ```python api_example.py theme={"system"}
    import requests
    def demo_call(input, 
                  model="gpt-4o",
                  token="YOUR_KEYWORDS_AI_API_KEY"
                  ):
        headers = {
            'Content-Type': 'application/json',
            'Authorization': f'Bearer {token}',
        }

        data = {
            'model': model,
            'messages': [{'role': 'user', 'content': input}],
            'customer_credentials': {
                'bedrock': {
                    'aws_access_key_id': "YOUR_BEDROCK_API_KEY",
                    'aws_secret_access_key': "YOUR_BEDROCK_API_BASE_URL",
                    'aws_region_name': "YOUR_BEDROCK_API_VERSION",
                }
            }
        }

        response = requests.post('https://api.keywordsai.co/api/chat/completions', headers=headers, json=data)
        return response

    messages = "Say 'Hello World'"
    print(demo_call(messages).json())
    ```
  </CodeGroup>
</Accordion>

## Requirements

1. Ensure your **deployment name** matches those listed on our [Models page](https://platform.keywordsai.co/platform/models).
2. Confirm that your models are available in the region specified by your credentials.
   <Warning>Credentials validation is not supported. Failure to comply with these requirements will result in errors!</Warning>

### How to get your AWS Bedrock credentials

1. Go to `https://aws.amazon.com/` and click on `Sign In to the Console`.
2. Choose your region and click on `Security credentials` in the top right corner.
3. Click on `Access keys` and then `Create New Access Key`.
4. You will see your `Access key ID` and `Secret access key`. Copy these values and use them in the `aws_access_key_id` and `aws_secret_access_key` fields in the request body.
5. You can find your `aws_region_name` in the URL of the AWS console. For example, if the URL is `https://us-west-2.console.aws.amazon.com/`, then the `aws_region_name` is `us-west-2`.
