Algolia AI / GenAI Toolkit / Guides

Create and manage Prompts

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

Before you begin

To create a prompt, 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.

Manage prompts with the dashboard

Create new prompts

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

  3. Click Create New Prompt.

    Create prompt from dashboard

  4. Enter a name for your Prompt. This will be used to easily identify your prompt later.

    Enter prompt name

  5. Select one of the pre-defined tones to use in the final prompt, computed by the GenAI Toolkit. By default the tone is set to natural.

    Select prompt tone

  6. Enter the detailed instructions for your prompt. They will be used to compute the final prompt that will be needed for generating responses.

    Enter prompt instructions

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

    Save prompt

Edit prompts

You can edit its details directly from the Dashboard. Start by selecting a prompt from the prompts Table.

Pick prompt from table

On the details screen you can edit the name, change the selected tone or modify the prompt instructions. To save your changes, click the Save Prompt button.

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

Duplicate prompts

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

Duplicate prompt

A new screen opens, pre-filled with the details from your base prompt. You can edit the name, select a new tone or add new instructions. To save your changes, click the Save Prompt button.

Delete prompts

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

Delete prompt

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

Manage prompts with the GenAI Toolkit API

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

Create a new prompt

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/prompt/ \
     -H 'Content-Type: application/json' \
     -H 'X-Algolia-Api-Key: ${API_KEY}' \
     -H 'X-Algolia-Application-ID: ${APPLICATION_ID}' \
     -d '{
      "name": "Compare phones by feature",
      "instructions": "Help buyers chose the right phone for their needs by providing relevant information and comparing the given products by feature.",
      "tone": "friendly",
      "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba3",
     }'

Parameters

name
type: string
Required

The name used to identify the prompt.

instructions
type: string
Required

The instructions / system prompt that will be provided to the Toolkit GenAI.

objectID
type: string

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

tone
type: string

The model will use a specific tone when provided (one of ‘natural’/’friendly’/’professional’, default: ‘natural’).

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 prompt.",
}

Update a prompt

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/prompt/ \
     -H 'Content-Type: application/json' \
     -H 'X-Algolia-Api-Key: ${API_KEY}' \
     -H 'X-Algolia-Application-ID: ${APPLICATION_ID}' \
     -d '{
      "name": "Compare phones by feature",
      "instructions": "Help buyers chose the right phone for their needs by providing relevant information and comparing the given products by feature.",
      "tone": "friendly",
      "objectID": "b4e52d1a-2509-49ea-ba36-f6f5c3a83ba3",
     }'

Parameters

objectID
type: string
Required

The ID of the prompt to be updated.

name
type: string

The name used to identify the prompt.

instructions
type: string

The instructions / system prompt that will be provided to the Toolkit GenAI.

tone
type: string

The model will use a specific tone when provided (one of ‘natural’/’friendly’/’professional’, default: ‘natural’).

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 updating the prompt.",
}

Delete a prompt

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/prompts/ \
     -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 prompts 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 prompts.",
}

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