Skip to main content

Knowledge Bases for Amazon Bedrock

Knowledge Bases for Amazon Bedrock is a fully managed support for end-to-end RAG workflow provided by Amazon Web Services (AWS). It provides an entire ingestion workflow of converting your documents into embeddings (vector) and storing the embeddings in a specialized vector database. Knowledge Bases for Amazon Bedrock supports popular databases for vector storage, including vector engine for Amazon OpenSearch Serverless, Pinecone, Redis Enterprise Cloud, Amazon Aurora (coming soon), and MongoDB (coming soon).


npm i @aws-sdk/client-bedrock-agent-runtime @langchain/community


import { AmazonKnowledgeBaseRetriever } from "@langchain/community/retrievers/amazon_knowledge_base";

const retriever = new AmazonKnowledgeBaseRetriever({
topK: 10,
knowledgeBaseId: "YOUR_KNOWLEDGE_BASE_ID",
region: "us-east-2",
clientOptions: {
credentials: {
accessKeyId: "YOUR_ACCESS_KEY_ID",
secretAccessKey: "YOUR_SECRET_ACCESS_KEY",

const docs = await retriever.getRelevantDocuments("How are clouds formed?");


API Reference:

Help us out by providing feedback on this documentation page: