Skip to main content
Before building a chat interface or generating summarized answers, you need to enable the feature, configure your indexes, and create a workspace. This setup is shared across all conversational search use cases.

Enable the chat completions feature

If you are using Meilisearch Cloud, enable chat completions from your project’s settings page under “Experimental features”. For self-hosted instances, enable the feature through the experimental features endpoint:
curl \
  -X PATCH 'MEILISEARCH_URL/experimental-features/' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "chatCompletions": true
  }'

Find your chat API key

Meilisearch automatically generates a “Default Chat API Key” with chatCompletions and search permissions on all indexes. Check if you have the key using:
curl \
  -X GET 'MEILISEARCH_URL/keys' \
  -H 'Authorization: Bearer MASTER_KEY'
Look for the key with the description “Default Chat API Key”.

Troubleshooting: Missing default chat API key

If your instance does not have a Default Chat API Key, create one manually:
curl \
  -X POST 'MEILISEARCH_URL/keys' \
  -H 'Authorization: Bearer MEILISEARCH_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "name": "Chat API Key",
    "description": "API key for chat completions",
    "actions": ["search", "chatCompletions"],
    "indexes": ["*"],
    "expiresAt": null
  }'

Configure your indexes

Configure the chat settings for each index you want to make available to the conversational search agent:
curl \
  -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/chat' \
  -H 'Authorization: Bearer MEILISEARCH_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "description": "A comprehensive database of TYPE_OF_DOCUMENT containing titles, descriptions, genres, and release dates to help users searching for TYPE_OF_DOCUMENT",
    "documentTemplate": "{% for field in fields %}{% if field.is_searchable and field.value != nil %}{{ field.name }}: {{ field.value }}\n{% endif %}{% endfor %}",
    "documentTemplateMaxBytes": 400
  }'
  • description tells the LLM what the index contains. A good description helps the agent decide which index to search and improves answer relevance
  • documentTemplate defines the document data Meilisearch sends to the AI provider. This template outputs all searchable fields in your documents, which may not be ideal if your documents have many fields. Consult the document template best practices article for more guidance
  • documentTemplateMaxBytes establishes a size limit for the document templates. Documents bigger than 400 bytes are truncated to ensure a good balance between speed and relevancy
You can also configure searchParameters to control how the LLM searches the index (hybrid search, result limits, sorting, etc.). See configure index chat settings for all available options.

Create a workspace

Chat completion workspaces are isolated configurations targeting different use cases. Each workspace can:
  • Use different LLM providers (OpenAI, Azure OpenAI, Mistral, vLLM)
  • Establish separate conversation contexts via system prompts
  • Access a specific set of indexes
Create a workspace by setting your LLM provider as its source:
curl \
  -X PATCH 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \
  -H 'Authorization: Bearer MEILISEARCH_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "source": "openAi",
    "apiKey": "PROVIDER_API_KEY",
    "prompts": {
      "system": "You are a helpful assistant. Answer questions based only on the provided context."
    }
  }'
Which fields are mandatory depends on your chosen provider. In most cases, you need to provide an apiKey. baseUrl is only mandatory for Azure OpenAI and vLLM. The prompts.system field gives the agent its baseline instructions. The prompts object accepts additional fields that help the agent formulate better searches.

Next steps

Your conversational search setup is complete. Choose how you want to use it:

Build a chat interface

Create a multi-turn conversational interface where users ask follow-up questions.

Generate summarized answers

Display concise AI-generated answers alongside traditional search results.