Manage indexes

An index is a basic unit for organizing and storing video data consisting of video embeddings and metadata. Indexes facilitate information retrieval and processing. The IndexesClientWrapper class provides methods to manage your indexes.

Properties

NameTypeDescription
videosVideosClientUse this property to manage the videos uploaded to this index.

Methods

Create an index

Description: This method creates a new index based on the provided parameters.

Function signature and example:

1def create(
2 self,
3 *,
4 index_name: str,
5 models: typing.Sequence[IndexesCreateRequestModelsItem],
6 addons: typing.Optional[typing.Sequence[str]] = OMIT,
7 request_options: typing.Optional[RequestOptions] = None,
8) -> IndexesCreateResponse:

Parameters

NameTypeRequiredDescription
index_namestrYesThe name of the new index. Use a succinct and descriptive name.
modelstyping.
Sequence
[IndexesCreateRequestModelsItem]
YesAn array of objects specifying the video understanding models and the model options you want to enable for this index. Each object is a dictionary with two keys: model_name and model_options.
addonstyping.
Optional
[typing.
Sequence[str]]
NoAn array of add-ons to enable, such as "thumbnail". If omitted, no add-ons are enabled.
request_optionstyping.
Optional
[RequestOptions]
NoRequest-specific configuration.

Return value: Returns an IndexesCreateResponse object containing the unique identifier of the newly created index.

API Reference: Create an index.

Related guide: Create indexes.

Retrieve an index

Description: This method retrieves details of a specific index.

Function signature and example:

1def retrieve(self, index_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> IndexSchema

Parameters

NameTypeRequiredDescription
index_idstrYesThe unique identifier of the index to retrieve.
request_optionstyping.Optional[RequestOptions]NoRequest-specific configuration.

Return value: Returns an IndexSchema object representing the retrieved index.

The IndexSchema class contains the following properties:

NameTypeDescription
idOptional[str]The unique identifier of the index. It is assigned by the platform when an index is created.
created_atOptional[str]The date and time, in the RFC 3339 format, that the index was created.
updated_atOptional[str]The date and time, in the RFC 3339 format, that the index has been updated.
expires_atOptional[str]The date and time, in the RFC 3339 format, when your index will expire. If you’re on the Free plan, the platform retains your index data for 90 days from creation. If you’re on the Developer plan, this field is set to null, indicating no expiration.
index_nameOptional[str]The name of the index.
total_durationOptional[float]The total duration, in seconds, of the videos in the index.
video_countOptional[float]The number of videos uploaded to this index.
modelsOptional[List[IndexModelsItem]]An array containing the list of the video understanding models enabled for this index.
addonsOptional[List[str]]The list of the add-ons that are enabled for this index.

The IndexModelsItem class contains the following properties:

NameTypeDescription
model_nameOptional[str]The name of the model.
model_optionsOptional[List[str]]An array of strings that contains the model options enabled for this index.

API Reference: Retrieve an index.

List indexes

Description: This method retrieves a paginated list of indexes based on the provided parameters. By default, the platform returns your indexes sorted by creation date, with the newest at the top of the list.

Function signature and example:

1def list(
2 self,
3 *,
4 page: typing.Optional[int] = None,
5 page_limit: typing.Optional[int] = None,
6 sort_by: typing.Optional[str] = None,
7 sort_option: typing.Optional[str] = None,
8 index_name: typing.Optional[str] = None,
9 model_options: typing.Optional[str] = None,
10 model_family: typing.Optional[str] = None,
11 created_at: typing.Optional[str] = None,
12 updated_at: typing.Optional[str] = None,
13 request_options: typing.Optional[RequestOptions] = None,
14) -> SyncPager[IndexSchema]

Parameters

NameTypeRequiredDescription
pagetyping.
Optional[int]
NoThe page number to retrieve. Default: 1.
page_limittyping.
Optional[int]
NoThe number of items per page. Default: 10. Max: 50.
sort_bytyping.
Optional[str]
NoThe field to sort on. The following options are available: “updated_at” - Sorts by the time when the item was updated, “created_at” - Sorts by the time when the item was created. Default: “created_at”.
sort_optiontyping.
Optional[str]
NoThe sorting direction. The following options are available: “asc”, “desc”. Default: “desc”.
index_nametyping.
Optional[str]
NoFilter by the name of an index.
model_optionstyping.
Optional[str]
NoFilter by the model options. When filtering by multiple model options, the values must be comma-separated. Example: "visual,audio").
model_familytyping.
Optional[str]
NoFilter by the model family. This parameter can take one of the following values: “marengo” or “pegasus”. You can specify a single value.
created_attyping.
Optional[str]
NoFilter indexes by the creation date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”). The platform returns the indexes that were created on the specified date at or after the given time.
updated_attyping.
Optional[str]
NoFilter indexes by the last update date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”). The platform returns the indexes that were last updated on the specified date at or after the given time.
request_optionstyping.
Optional[RequestOptions]
NoRequest-specific configuration.

Return value: Returns a SyncPager[IndexSchema] object containing a paginated list of IndexSchema objects, representing the indexes that match the specified criteria. See the Retrieve an index section above for complete property details.

The SyncPager[T] class contains the following properties and methods:

NameTypeDescription
itemsOptional[List[T]]A list containing the current page of items. Can be None.
has_nextboolIndicates whether there is a next page to load.
get_nextOptional[Callable[[], Optional[SyncPager[T]]]]A callable function that retrieves the next page. Can be None.
responseOptional[BaseHttpResponse]The HTTP response object. Can be None.
next_page()Optional[SyncPager[T]]Calls get_next() if available and returns the next page object.
__iter__()Iterator[T]Allows iteration through all items across all pages using for loops.
iter_pages()Iterator[SyncPager[T]]Allows iteration through page objects themselves.

API Reference: List indexes.

Update an index

Description: This method updates the name of an existing index.

Function signature and example:

1def update(
2 self, index_id: str, *, index_name: str, request_options: typing.Optional[RequestOptions] = None
3) -> None

Parameters:

NameTypeRequiredDescription
index_idstrYesThe unique identifier of the index to update.
index_namestrYesThe new name of the index.
request_optionstyping.
Optional[RequestOptions]
NoRequest-specific configuration.

Return Value: None. This method doesn’t return any data upon successful completion.

API Reference: Update an index.

Delete an index

Description: This method deletes an existing index.

Function signature and example:

1def delete(self, index_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None

Parameters:

NameTypeRequiredDescription
index_idstringYesThe unique identifier of the index to delete.
request_optionstyping.
Optional[RequestOptions]
NoRequest-specific configuration.

Return value: None. This method doesn’t return any data upon successful completion.

API Reference: Delete an index

Error codes

This section lists the most common error messages you may encounter while managing indexes.

  • index_option_cannot_be_changed
    • Index option cannot be changed. Please remove index_options parameter and try again. If you want to change index option, please create new index.
  • index_engine_cannot_be_changed
    • Index engine cannot be changed. Please remove engine_id parameter and try again. If you want to change engine, please create new index.
  • index_name_already_exists
    • Index name {index_name} already exists. Please use another unique name and try again.