/chats
route enables AI-powered conversational search by integrating Large Language Models (LLMs) with your Meilisearch data.
This is an experimental feature. Use the Meilisearch Cloud UI or the experimental features endpoint to activate it:
Conversational search is still in early development. Conversational agents may occasionally hallucinate inaccurate and misleading information, so it is important to closely monitor it in production environments.
Authorization
When implementing conversational search, use an API key with access to both thesearch
and chatCompletions
actions such as the default chat API key. You may also use tenant tokens instead of an API key, provided you generate the tokens with a key that has access to the required actions.
Chat queries only search the indexes its API key can access. The default chat API key has access to all indexes. To limit access, you must either create a new key, or generate a tenant token from the default chat API key.
Chat workspaces
Workspaces are groups of chat settings tailored towards specific use cases. You must configure at least on workspace to use chat completions.Chat workspace object
Name | Type | Description |
---|---|---|
uid | String | Unique identifier for the chat completions workspace |
Chat workspace settings object
source
Type: StringDefault value: N/A
Description: Name of the chosen embeddings provider. Must be one of:
"openAi"
, "azureOpenAi"
, "mistral"
, "gemini"
, or "vLlm"
orgId
Type: StringDefault value: N/A
Description: Organization ID used to access the LLM provider. Required for Azure OpenAI, incompatible with other sources
projectId
Type: StringDefault value: N/A
Description: Project ID used to access the LLM provider. Required for Azure OpenAI, incompatible with other sources
apiVersion
Type: StringDefault value: N/A
Description: API version used by the LLM provider. Required for Azure OpenAI, incompatible with other sources
deploymentId
Type: StringDefault value: N/A
Description: Deployment ID used by the LLM provider. Required for Azure OpenAI, incompatible with other sources
baseUrl
Type: StringDefault value: N/A
Description: Base URL Meilisearch should target when sending requests to the embeddings provider. Must be the full URL preceding the
/chat/completions
fragment. Required for Azure OpenAI and vLLM
apiKey
Type: StringDefault value: N/A
Description: API key to access the LLM provider. Optional for vLLM, mandatory for all other providers
prompts
Type: ObjectDefault value: N/A
Description: Prompts giving baseline context to the conversational agent. The prompts object accepts the following fields:
prompts.system
: Default prompt giving the general usage context of the conversational search agent. Example: “You are a helpful bot answering questions on how to use Meilisearch”prompts.searchDescription
: An internal description of the Meilisearch chat tools. Use it to instruct the agent on how and when to use the configured tools. Example: “Tool for retrieving relevant documents. Use it when users ask for factual information, past records, or resources that might exist in indexed content.”prompts.QParam
: Description of expected user input and the desired output. Example: “Users will ask about Meilisearch. Provide short and direct keyword-style queries.”prompts.IndexUidParam
: Instructions describing each index the agent has access to and how to use them. Example: “If user asks about code or API or parameters, use the index calleddocumentation
.”
List chat workspaces
GET
/chats
offset
and limit
query parameters.
Query parameters
Query parameter | Description | Default value |
---|---|---|
offset | Number of workspaces to skip | 0 |
limit | Number of workspaces to return | 20 |
Response
Name | Type | Description |
---|---|---|
results | Array | An array of workspaces |
offset | Integer | Number of workspaces skipped |
limit | Integer | Number of workspaces returned |
total | Integer | Total number of workspaces |
Example
Response: 200 Ok
Get one chat workspace
GET
/chats/{workspace_uid}
Path parameters
Name | Type | Description |
---|---|---|
workspace_uid * | String | uid of the requested index |
Example
Response: 200 Ok
Get chat workspace settings
GET
/chats/{workspace_uid}/settings
Path parameters
Name | Type | Description |
---|---|---|
workspace_uid | String | The workspace identifier |
Response: 200 OK
Returns the settings object. For security reasons, the apiKey
field is obfuscated.
Example
Create a chat workspace and update chat workspace settings
PATCH
/chats/{workspace_uid}/settings
Path parameters
Name | Type | Description |
---|---|---|
workspace_uid | String | The workspace identifier |
Settings parameters
Name | Type | Description |
---|---|---|
source | String | LLM source: "openAi" , "azureOpenAi" , "mistral" , "gemini" , or "vLlm" |
orgId | String | Organization ID for the LLM provider |
projectId | String | Project ID for the LLM provider |
apiVersion | String | API version for the LLM provider |
deploymentId | String | Deployment ID for the LLM provider |
baseUrl | String | Base URL for the provider |
apiKey | String | API key for the LLM provider |
prompts | Object | Prompts object containing system prompts and other configuration |
Prompt parameters
Name | Type | Description |
---|---|---|
[system] (#prompts) | String | A prompt added to the start of the conversation to guide the LLM |
searchDescription | String | A prompt to explain what the internal search function does |
searchQParam | String | A prompt to explain what the q parameter of the search function does and how to use it |
searchIndexUidParam | String | A prompt to explain what the indexUid parameter of the search function does and how to use it |
Request body
Response: 200 OK
Returns the updated settings object. apiKey
is write-only and will not be returned in the response.
Examples
Reset chat workspace settings
DELETE
/chats/{workspace_uid}/settings
Path parameters
Name | Type | Description |
---|---|---|
workspace_uid | String | The workspace identifier |
Response: 200 OK
Returns the settings object without the apiKey
field.
Example
Chat completions
After creating a workspace, you can use the chat completions API to create a conversational search agent.Stream chat completions
POST
/chats/{workspace_uid}/chat/completions
Path parameters
Name | Type | Description |
---|---|---|
workspace | String | The chat completion workspace unique identifier (uid) |
Request body
Name | Type | Required | Description |
---|---|---|---|
model | String | Yes | Model the agent should use when generating responses |
messages | Array | Yes | Array of message objects |
stream | Boolean | No | Enable streaming responses. Must be true if specified |
Meilisearch chat completions only supports streaming responses (
stream: true
).Message object
Name | Type | Description |
---|---|---|
role | String | Message role: "system" , "user" , or "assistant" |
content | String | Message content |
role
Specifies the message origin: Meilisearch (system
), the LLM provider (assistant
), or user input (user
)