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

# AWS Bedrock Knowledge Bases

> Create, manage, and connect your LLMs to organisational data using AWS Bedrock Knowledge Bases through Prisma AIRS AI Gateway.

AWS Bedrock Knowledge Bases enables you to give foundation models access to your company's private data sources, delivering more relevant, accurate, and customized responses through Retrieval Augmented Generation (RAG).

With the AI Gateway's integration, you can seamlessly create, connect to, and query AWS Bedrock Knowledge Bases while gaining enterprise features like observability, caching, and reliability - all through a unified API that simplifies authentication.

## What is AWS Bedrock Knowledge Bases?

AWS Bedrock Knowledge Bases is a fully managed service that implements the entire RAG workflow - from data ingestion to retrieval and prompt augmentation. It allows you to:

* **Connect to Multiple Data Sources**: Automatically fetch data from Amazon S3, Confluence, Salesforce, SharePoint, and more.
* **Managed Vector Storage**: Store embeddings in supported vector databases like Amazon Aurora, OpenSearch, Neptune, MongoDB, Pinecone, or Redis.
* **Advanced Retrieval**: Use semantic search and filtering for accurate information retrieval.
* **Source Attribution**: All retrieved information includes citations to improve transparency and minimize hallucinations.

## Prerequisites

Before integrating AWS Bedrock Knowledge Bases with the AI Gateway, ensure you have:

1. **AWS Account** with Bedrock access enabled.
2. **AWS Credentials** with permissions to create and access Bedrock Knowledge Bases, configured in the AI Gateway.
3. **Strata Cloud Manager account** with an API key.
4. An **IAM Role** with the necessary permissions for Bedrock to access your data sources.
5. A **Vector Store** (like Amazon OpenSearch Serverless) to store the indexed data.

## Setup Guide

### Step 1: Create an AWS Integration in the AI Gateway

You need to connect your AWS account to the AI Gateway. This allows the AI Gateway to make authenticated requests to AWS on your behalf.

<Steps>
  <Step title="Navigate to Integrations">
    Navigate to the [Integrations](https://stratacloudmanager.paloaltonetworks.com/) section on the AI Gateway's Sidebar. This is where you'll connect your LLM providers.

    1. Find **Bedrock** and click **Connect**.
    2. In the "Create New Integration" window:
       * Enter a **Name** for reference (e.g., `aws-bedrock-prod`).
       * Enter a **Slug** for the integration (e.g., `aws-bedrock-prod`).
       * Enter your **AWS Access Key ID**, **Secret Access Key**, and **Default Region**.
    3. Click **Next Step**.

    <Note>
      The **Slug** you create here will be used with an `@` prefix as the `provider` in your AI Gateway client initialization (e.g., `@aws-bedrock-prod`).
    </Note>
  </Step>

  <Step title="Configure Models">
    On the model provisioning page:

    * Leave all models selected (or customize).
    * Toggle "Automatically enable new models" if desired.

    Click **Create Integration** to complete the integration.
  </Step>
</Steps>

### Step 2: Create a Knowledge Base

To create an AWS Bedrock Knowledge Base, you use the AI Gateway's `put` method. This acts as a proxy, sending a signed request directly to the AWS `PUT /knowledgebases/` API endpoint. The AI Gateway handles the complex AWS Signature Version 4 authentication process for you.

When initializing the AI Gateway client, you must provide a `custom_host` that points to the AWS Bedrock Agent API endpoint for your region.

<Card href="https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-create.html" title="AWS Docs: Create a knowledge base for Amazon Bedrock" />

### Step 3: Retrieve from a Knowledge Base

Once your knowledge base is created and has finished syncing, you can query it using the AI Gateway's `post` method. This request is sent to the AWS `retrieve` API endpoint: `POST /knowledgebases/{knowledgeBaseId}/retrieve`.

<Note>
  **Important:** For retrieval, the `custom_host` URL is different. You must use the **Bedrock Agent Runtime** endpoint for your region (e.g., `bedrock-agent-runtime.us-east-1.amazonaws.com`).
</Note>

### Step 4: Query the Knowledge Base and Generate a Response (RAG)

This step demonstrates the complete Retrieval-Augmented Generation (RAG) pipeline. First, we retrieve relevant context from the knowledge base. Then, we use that context to ground a large language model, enabling it to generate an informed response.

<Note>
  Notice that we use two different AI Gateway client initializations. The first one includes a `custom_host` to target the Bedrock Agent Runtime for retrieval. The second one is a standard client for chat completion.
</Note>

## Next Steps

Now that you can create and build a full RAG application with your knowledge base, you can explore other AI Gateway features to enhance your application:

* Explore [AI Gateway Observability](/docs/aigw/product/observability) to monitor your RAG pipeline.
* Set up [Guardrails](/docs/aigw/product/guardrails) to ensure safe and compliant responses.
* Implement Prompt Management for your RAG prompts.
* Configure [Fallbacks](/docs/aigw/product/ai-gateway/fallbacks) for high availability.

<Note>
  For enterprise support with your AWS Bedrock integration, contact our \[enterprise team]\([https://www.paloaltonetworks.com/ai-security/ai-gateway#:\~:text=See%20Prisma%20AIRS%20AI%20Gateway%20in%20Action](https://www.paloaltonetworks.com/ai-security/ai-gateway#:~:text=See%20Prisma%20AIRS%20AI%20Gateway%20in%20Action)
</Note>


## Related topics

- [AWS Bedrock](/docs/aigw/integrations/llms/bedrock/aws-bedrock.md)
- [AWS Bedrock Guardrails](/docs/aigw/integrations/guardrails/bedrock-guardrails.md)
- [Control Flow](/docs/aigw/integrations/agents/control-flow.md)
- [Bring Your own Agents](/docs/aigw/integrations/agents/bring-your-own-agents.md)
- [Langchain Agents](/docs/aigw/integrations/agents/langchain-agents.md)
