Algolia AI / GenAI Toolkit / Guides

Create and manage data sources

GenAI Toolkit is currently in private beta according to the Algolia Terms of Service (“Beta Services”).

Before you begin

To create a data source, you need the GenAI Toolkit feature in your Algolia plan, and an index with the product data you want to use for your GenAI applications.

Manage data sources with the dashboard

Create new data sources

  1. Select Generative AI in the Algolia dashboard.
  2. On the left sidebar, select Data Sources.

  3. Click Create New Data Source.

    Create data source from dashboard

  4. Enter a name for your data source. This will be used to easily identify your data sources later.

    Enter data source name

  5. Select one of your Algolia indices.

    Choose index for data source

  6. You can apply additional filters to your selected index to refine and enhance the relevance of your data source. You can view the changes in the preview section.

    Select filters for data source

  7. Once you are satisfied with your configuration, click Save Data Source.

    Save data source

Edit data sources

You can edit the details of your data sources directly in the Algolia dashboard. Start by selecting a data source from the table.

Pick data source from table

On the details screen, you can edit the name, change the selected index, or modify the filters. To save your changes, click Save Data Source.

Modifying a data source that you used for generating responses may impact those responses. Review and optionally regenerate the responses that depend on this data source.

Duplicate data sources

You can use one data source as a template for creating a new one. From the data source table, choose your base data source, click More and select Duplicate.

Duplicate data source

A new screen opens, pre-filled with the details from your base data source. You can edit the name, select a different index, or apply new filters. To save your changes, click Save Data Source button.

Delete data sources

To delete a data source in the dashboard, choose the data source you want to delete from the data source table, click More and select Delete.

Delete data source

Deleting a data source that was used for generating responses impacts those responses. You can choose how to handle this: you can either delete the data source and keep the responses that rely on it, or you can delete the associated responses together with the data source.

Manage data sources with the GenAI Toolkit API

You can manage your data sources with the GenAI Toolkit API.

Create a new data source

You need an API Key with the following ACLs: addObject, settings, editSettings.

1
2
3
4
5
6
7
8
9
10
curl -X POST https://generative-ai.algolia.com/create/data_source/ \
     -H 'Content-Type: application/json' \
     -H 'X-Algolia-Api-Key: ${API_KEY}' \
     -H 'X-Algolia-Application-ID: ${APPLICATION_ID}' \
     -d '{
        "name": "Phones",
        "source": "products",
        "filters": "category:\"phones\" AND price>500",
        "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1",
     }'

Parameters

name
type: string
Required

The name used to identify the data source.

source
type: string
Required

The Algolia index used for retrieving contextual information.

objectID
type: string

A unique identifier used for storing the data source. If not provided, the API will automatically generate a new one.

filters
type: string

Filters used for further customizing the retrieval.

1
2
3
4
{
  [...]
  "filters": "category:\"phones\" AND price>500",
}

Returns

1
2
3
4
5
6
7
8
9
10
// Success: HTTP Status Code = 200
{
  "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1",
}

// Error: HTTP Status Code != 200
{
  "name": "Error",
  "message": "Error saving the data source.",
}

Update a data source

You need an API Key with the following ACLs: addObject, search.

1
2
3
4
5
6
7
8
9
10
curl -X POST https://generative-ai.algolia.com/update/data_source/ \
     -H 'Content-Type: application/json' \
     -H 'X-Algolia-Api-Key: ${API_KEY}' \
     -H 'X-Algolia-Application-ID: ${APPLICATION_ID}' \
     -d '{
        "name": "Phones",
        "source": "products",
        "filters": "category:\"phones\" AND price>500",
        "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1",
     }'

Parameters

objectID
type: string
Required

The ID of the data source to be updated.

name
type: string

The name used to identify the data source.

source
type: string

The Algolia index used for retrieving contextual information.

filters
type: string

Filters used for further customizing the retrieval.

1
2
3
4
{
  [...]
  "filters": "category:\"phones\" AND price>500",
}

Returns

1
2
3
4
5
6
7
8
9
10
// Success
{
  "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1",
}

// Error
{
  "name": "Error",
  "message": "Error updating the data source.",
}

Delete data sources

You need an API Key with the following ACLs: deleteObject, search.

1
2
3
4
5
6
7
8
curl -X POST https://generative-ai.algolia.com/delete/data_sources/ \
     -H 'Content-Type: application/json' \
     -H 'X-Algolia-Api-Key: ${API_KEY}' \
     -H 'X-Algolia-Application-ID: ${APPLICATION_ID}' \
     -d '{
        "objectIDs": ["b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1"],
        "deleteLinkedResponses": false,
     }'

Parameters

objectIDs
type: string[]
Required

List of IDs of the data sources to be deleted.

deleteLinkedResponses
type: boolean

Instructions for cascading the deletion of the linked responses as well or not. (default: false).

Returns

1
2
3
4
5
6
7
8
9
10
// Success: HTTP Status Code = 200
{
  "message": "Successfully deleted data sources.",
}

// Error: HTTP Status Code != 200
{
  "name": "Error",
  "message": "Error when deleting the data sources.",
}
Did you find this page helpful?