Skip to content

Bedrock Agent  >  Operations  >  create_knowledge_base

create_knowledge_base

Operation

create_knowledge_base async

create_knowledge_base(input: CreateKnowledgeBaseInput, plugins: list[Plugin] | None = None) -> CreateKnowledgeBaseOutput

Creates a knowledge base. A knowledge base contains your data sources so that Large Language Models (LLMs) can use your data. To create a knowledge base, you must first set up your data sources and configure a supported vector store. For more information, see Set up a knowledge base.

Note

To create a managed knowledge base, provide a managedKnowledgeBaseConfiguration during creation. For more information, see Build a managed knowledge base.

  • Provide the name and an optional description.

  • Provide the Amazon Resource Name (ARN) with permissions to create a knowledge base in the roleArn field.

  • For managed knowledge bases, set embeddingModelType to MANAGED to use the service-managed embedding model, or CUSTOM with an embeddingModelArn to use your own. To use your own KMS key for encryption, provide the ARN in serverSideEncryptionConfiguration. No vector store configuration is required for managed knowledge bases.

  • For self-managed knowledge bases, provide the embedding model to use in the embeddingModelArn field in the knowledgeBaseConfiguration object.

  • For self-managed knowledge bases, provide the configuration for your vector store in the storageConfiguration object.

  • For an Amazon OpenSearch Service database, use the opensearchServerlessConfiguration object. For more information, see Create a vector store in Amazon OpenSearch Service.

  • For an Amazon Aurora database, use the RdsConfiguration object. For more information, see Create a vector store in Amazon Aurora.

  • For a Pinecone database, use the pineconeConfiguration object. For more information, see Create a vector store in Pinecone.

  • For a Redis Enterprise Cloud database, use the redisEnterpriseCloudConfiguration object. For more information, see Create a vector store in Redis Enterprise Cloud.

Parameters:

Name Type Description Default
input CreateKnowledgeBaseInput

An instance of CreateKnowledgeBaseInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
CreateKnowledgeBaseOutput

An instance of CreateKnowledgeBaseOutput.

Input

CreateKnowledgeBaseInput dataclass

Dataclass for CreateKnowledgeBaseInput structure.

Attributes

client_token class-attribute instance-attribute
client_token: str | None = None

A unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency.

description class-attribute instance-attribute
description: str | None = None

A description of the knowledge base.

knowledge_base_configuration class-attribute instance-attribute
knowledge_base_configuration: KnowledgeBaseConfiguration | None = None

Contains details about the embeddings model used for the knowledge base.

name class-attribute instance-attribute
name: str | None = None

A name for the knowledge base.

role_arn class-attribute instance-attribute
role_arn: str | None = None

The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the knowledge base.

storage_configuration class-attribute instance-attribute
storage_configuration: StorageConfiguration | None = None

Contains details about the configuration of the vector database used for the knowledge base.

tags class-attribute instance-attribute
tags: dict[str, str] | None = None

Specify the key-value pairs for the tags that you want to attach to your knowledge base in this object.

Output

CreateKnowledgeBaseOutput dataclass

Dataclass for CreateKnowledgeBaseOutput structure.

Attributes

knowledge_base instance-attribute
knowledge_base: KnowledgeBase

Contains details about the knowledge base.