Algolia AI / GenAI Toolkit / Guides

Generate and manage responses

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

Before you begin

To generate a response, you need the GenAI Toolkit feature in your Algolia plan, and an index containing the product data you want to use for your GenAI applications, as well as a Prompt and a Data source.

Manage responses with the dashboard

Generate new responses

You can use the Response Playground to see how a query would generate content for a given data source and prompt.

  1. Select Generative AI in the Algolia dashboard.
  2. On the left sidebar, select Response Playground.
  3. Choose a prompt.

    Select prompt

  4. Choose a data source.

    Select data source

  5. Optionally, you can further refine your data source by applying additional filters. Those filters will not affect the selected data source, they will only impact the response.

    Select additional filters

  6. Enter a user query and click Generate to generate and preview the response.

    Generate response

  7. To save the generated response, click the Save Response button.

    Save generated response

To regenerate a response, you can change the filters, enter a different query, select another prompt or data source, or you directly edit the selected prompt or data source from the playground, then click Regenerate.

Manage responses

You can find all the generated responses in the Generated responses section. Here you can view the response details or you can delete responses.

Preview response

Manage responses with the GenAI Toolkit API

You can manage your responses with the GenAI Toolkit API.

Generate a new response

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

1
2
3
4
5
6
7
8
9
10
11
12
13
curl -X POST https://generative-ai.algolia.com/generate/response/ \
     -H 'Content-Type: application/json' \
     -H 'X-Algolia-Api-Key: ${API_KEY}' \
     -H 'X-Algolia-Application-ID: ${APPLICATION_ID}' \
     -d '{
        "query": "Compare iPhone 13 and Samsung S21",
        "dataSourceID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1",
        "promptID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba3",
        "additionalFilters": "model":\"iPhone 13\" OR "model":\"Samsung S21\",
        "save": true,
        "use_cache": false,
        "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba9",
     }'

Parameters

dataSourceID
type: string
Required

The identifier for the previously defined data source.

promptID
type: string
Required

The identifier of the previously defined prompt.

logRegion
type: string
Required

The identifier of the region needed for running the LLM router: us or de.(de is considered eu)

objectID
type: string

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

additionalFilters
type: string

Optional filters used for further customizing the retrieval. Will be taken into account alongside the data source filters, if any, without overwriting them/adding them to the data source object.

1
2
3
4
{
  [...]
  "additionalFilters": "category:\"phones\" AND price>500",
}
save
type: boolean

Instructions for saving the response, along with the configuration provided in the request. (default: true)

useCache
type: boolean

When true, if a previous response was generated with save:true, the API will return that cached response.

origin
type: string

The origin of the request: dashboard or api. (default: api)

Returns

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Success: HTTP Status Code = 200
{
  "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba9",
  "response": "The iPhone 13 features a 6.1-inch Super Retina display, while the Samsung Galaxy S21 has a slightly smaller 6.2-inch AMOLED screen. ...",
  "query": "Compare iPhone 13 and Samsung S21",
  "dataSourceID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1",
  "promptID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba3",
  "createdAt": "00",
}

// Error: HTTP Status Code != 200
{
  "name": "Error",
  "message": "Error generating the response.",
}

Delete a response

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

1
2
3
4
5
6
7
curl -X POST https://generative-ai.algolia.com/delete/responses/ \
     -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-f6f5c3a83ba9"],
     }'

Parameters

objectIDs
type: string[]
Required

List of IDs of the responses to be deleted.

Returns

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

// Error: HTTP Status Code != 200
{
  "name": "Error",
  "message": "Error when deleting the responses.",
}

Retrieve a response

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

1
2
3
4
curl -X GET https://generative-ai.algolia.com/get/response/${objectID}/ \
     -H 'Content-Type: application/json' \
     -H 'X-Algolia-Api-Key: ${API_KEY}' \
     -H 'X-Algolia-Application-ID: ${APPLICATION_ID}'

Parameters

objectID
type: string
Required

The ID of the response to be retrieved.

Returns

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Success: HTTP Status Code = 200
{
  "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba9",
  "response": "The iPhone 13 features a 6.1-inch Super Retina display, while the Samsung Galaxy S21 has a slightly smaller 6.2-inch AMOLED screen. ...",
  "query": "Compare iPhone 13 and Samsung S21",
  "dataSourceID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba1",
  "promptID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba3",
  "additionalFilters": "model":\"iPhone 13\" OR "model":\"Samsung S21\",
  "save": true,
  "useCache": false,
  "origin": "api",
  "createdAt": "000",
  "updatedAt": "000",
}

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