Create a knowledge store

This guide shows you how to create a knowledge store and optionally customize what the platform extracts during indexing.

Key concepts

  • Knowledge store: A persistent store of your videos and images plus the understanding the platform derives from them — spatiotemporal context, a typed ontology, and embeddings — that together enable corpus-level reasoning.
  • Ingestion configuration: An optional set of instructions that controls what the platform extracts during indexing. You can provide a natural-language description or a JSON schema.

Prerequisites

  • To use the platform, you need an API key:

    1

    If you don’t have an account, sign up for a free account.

    2

    Go to the API Keys page.

    3

    If you need to create a new key, select the Create API Key button. Enter a name and set the expiration period. The default is 12 months.

    4

    Select the Copy icon next to your key to copy it to your clipboard.

  • Depending on the programming language you are using, install the TwelveLabs SDK by entering one of the following commands:

    $pip install twelvelabs

Example

Copy and paste the code below, replacing the placeholders surrounded by <> with your values.

1from twelvelabs import TwelveLabs
2
3client = TwelveLabs(api_key="<YOUR_API_KEY>")
4
5store = client.knowledge_stores.create(
6 name="<YOUR_KNOWLEDGE_STORE_NAME>",
7 # ingestion_config=..., # Optional. Shape what the platform extracts during indexing.
8 # metadata={"team": "marketing", "quarter": "2026-Q1"}, # Optional. Up to 16 key-value pairs.
9)
10print(f"Knowledge store created: {store.id}")

Code explanation

To create a knowledge store, call the knowledge_stores.create method.
Parameters:

  • name: A name for the knowledge store.
  • (Optional) ingestion_config: An object that shapes what the platform extracts from your content during indexing. For the available approaches, see the Configure ingestion page.
  • (Optional) metadata: An object of up to 16 key-value pairs (string keys and values) to label and organize your stores.

Return value: An object of type KnowledgeStore with a field named id representing the unique identifier of the newly created knowledge store.

Next steps

Jupyter notebook

Open In Colab