Create Index

Create Index

This method allows you to create an index for a knowledge base.

The index defines how document contents are embedded. For example, it allows you to define the embeddings model to use by specifying the routing_name of the Model Endpoint to use. Additionally, you can specify how to divide the contents of each document into smaller "chunks"; bigger chunks may provide better context when they are sent to an LLM for answering questions, but smaller chunks may help identify and select relevant document parts. Choosing the right embedding model and best chunking strategy depends on your data and use-case and may require some experimentation.

Note that you cannot modify an index after its creation. The reason is that all documents in an index must be embedded in the same way. If core properties of the index (such as the embeddings model in use) are changed after the initial insert, it would no longer be possible to meaningfully search, compare, or rank embeddings in the index.

Request
URI
POST
https://{api_host}/api/v1/control/knowledge-bases/{knowledge_base_id}/indexes
COPY
Path Parameters
string
knowledge_base_id
Required

knowledge_base_id


Request Body
IndexCreateRequest of type(s) application/json
Required

Show optional properties

{
    "embeddings_model_endpoint": "string",
    "text_splitting": "string",
    "chunk_size": 0
}
{
    "name": "string",
    "description": "string",
    "embeddings_model_endpoint": "string",
    "text_splitting": "string",
    "chunk_size": 0,
    "chunk_overlap": 0
}
string
name
Optional
Constraints: maxLength: 256

Name of the index.

string
description
Optional

Description of the index.

string
embeddings_model_endpoint
Required

ID of the model to be used by the index for generating embeddings.

string
text_splitting
Required

Method for chunking text for embedding

integer
chunk_size
Required
Constraints: minimum: 100

Maximum size (in tokens) of the text chunks. This must be at least 100 to accomodate for content metadata embedded alongside each chunk of text.

integer
chunk_overlap
Optional
Constraints: minimum: 0 default: 0

Size of the chunk overlap (in tokens) when splitting text.

Authentication
This operation uses the following authentication methods.
Responses
201

Successful Response

Returns Index of type(s) application/json
"Index Object"
string As uuid As uuid
id
Required

ID of the index.

string
name
Optional
Constraints: maxLength: 256

Name of the index.

string
description
Optional

Description of the index.

string
embeddings_model_endpoint
Required

ID of the model to be used by the index for generating embeddings.

string
text_splitting
Required

Method for chunking text for embedding

integer
chunk_size
Required
Constraints: minimum: 100

Maximum size (in tokens) of the text chunks. This must be at least 100 to accomodate for content metadata embedded alongside each chunk of text.

integer
chunk_overlap
Optional
Constraints: minimum: 0 default: 0

Size of the chunk overlap (in tokens) when splitting text.

string As uuid As uuid
knowledge_base_id
Required

ID of the knowledge base of the index.

string
object
Optional
Constraints: default: index

Object type, which is always index.

integer
created_at
Required

Unix timestamp (in seconds) when the index was created.

integer
last_indexed_at
Optional

Unix timestamp (in seconds) when the index contents were last indexed.

string As uuid As uuid
last_indexed_by_id
Optional

ID of the most recent indexing job that affected this index.

integer
num_documents
Optional
Constraints: minimum: 0 default: 0

Total number of documents in the index.

string
status
Required

Availability status of the index.

Possible values are : AVAILABLE, ERROR,
array of string
status_errors
Optional

Details of the index error status, if the index is not available.

Possible values are : AGENT_ID_NOT_FOUND, FAILED_TO_PAGINATE_LIST, AGENT_SESSION_ID_NOT_FOUND, INDEX_NOT_FOUND, INDEX_NOT_REACHABLE, ROUTE_TO_MODEL_NOT_FOUND, INVALID_MODEL_TYPE_FOR_AGENT, AGENT_SESSION_EXPIRED, UNEXPECTED_MODEL, INVALID_RESPONSE_FROM_MODEL_ENDPOINT, INVALID_INFERENCE_REQUEST_FOR_MODEL_TYPE, DISALLOWED_ROLE, VALIDATION_ERROR, MAX_LENGTH_METADATA_REACHED, INVALID_AGENT_ATTRIBUTE, KNOWLEDGE_BASE_INVALID_STATE, DATA_SOURCE_NOT_FOUND, DATA_SOURCE_STILL_LINKED_TO_KNOWLEDGE_BASE, KNOWLEDGE_BASE_NOT_FOUND, DOCUMENT_NOT_FOUND, EMPTY_DOCUMENT_FILE, DOCUMENT_EXCEEDS_MAX_UPLOAD_SIZE, INDEXING_NOT_FOUND, NO_ACTIVE_INDEXING, ERROR_NOT_FOUND, INDEX_FOR_KNOWLEDGE_BASE_ALREADY_EXISTS, UNSUPPORTED_CONFIGURATION, PENDING_INDEXING_ALREADY_EXISTS_FOR_KB, CREATING_INDEXING_FOR_LOCAL_FILES_KB_NOT_ALLOWED, KNOWLEDGE_BASE_DATA_SOURCE_NOT_UNLINKING, KNOWLEDGE_BASE_DATA_SOURCE_NOT_FOUND, KNOWLEDGE_BASE_DATA_SOURCE_ALREADY_EXISTS, KNOWLEDGE_BASE_LINK_DATA_SOURCE_NOT_SUPPORTED, KNOWLEDGE_BASE_UPLOAD_NOT_SUPPORTED_FOR_DATA_SOURCE, KNOWLEDGE_BASE_DELETE_NOT_SUPPORTED_FOR_DATA_SOURCE, KNOWLEDGE_BASE_DELETE_NOT_SUPPORTED_WHILE_AGENT_IS_LINKED, KNOWLEDGE_BASE_DELETE_CONFLICT, DOCUMENT_NOT_IN_DELETABLE_STATE, COMPLETION_MODEL_ENDPOINT_UNAVAILABLE, EMBEDDING_MODEL_ENDPOINT_UNAVAILABLE, EMBEDDING_MODEL_ENDPOINT_BAD_TYPE,

400

Unexpected embeddings model endpoint.

Operation doesn't return any data structure

404

Invalid knowledge base ID.

Operation doesn't return any data structure

409

Index already created for the given knowledge base.

Operation doesn't return any data structure

422

Validation Error

Returns HTTPValidationError of type(s) application/json
"HTTPValidationError Object"
array of object
detail
Optional

detail


Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"embeddings_model_endpoint:"string","text_splitting:"string","chunk_size:"integer"}' https://{api_host}/api/v1/control/knowledge-bases/{knowledge_base_id}/indexes