Skip to main content
The /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 the search 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

Chat workspace settings object

source

Type: String
Default value: N/A
Description: Name of the chosen embeddings provider. Must be one of: "openAi", "azureOpenAi", "mistral", "gemini", or "vLlm"

orgId

Type: String
Default value: N/A
Description: Organization ID used to access the LLM provider. Required for Azure OpenAI, incompatible with other sources

projectId

Type: String
Default value: N/A
Description: Project ID used to access the LLM provider. Required for Azure OpenAI, incompatible with other sources

apiVersion

Type: String
Default value: N/A
Description: API version used by the LLM provider. Required for Azure OpenAI, incompatible with other sources

deploymentId

Type: String
Default value: N/A
Description: Deployment ID used by the LLM provider. Required for Azure OpenAI, incompatible with other sources

baseUrl

Type: String
Default 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: String
Default value: N/A
Description: API key to access the LLM provider. Optional for vLLM, mandatory for all other providers

prompts

Type: Object
Default 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 called documentation.”

List chat workspaces

GET
/chats
List all chat workspaces. Results can be paginated by using the offset and limit query parameters.

Query parameters

Response

Example

Response: 200 Ok

Get one chat workspace

GET
/chats/{workspace_uid}
Get information about a workspace.

Path parameters

Example

Response: 200 Ok

Get chat workspace settings

GET
/chats/{workspace_uid}/settings
Retrieve the current settings for a chat workspace.

Path parameters

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
Configure the LLM provider and settings for a chat workspace. If a workspace does not exist, querying this endpoint will create it.

Path parameters

Settings parameters

Prompt parameters

Request body

All fields are optional. Only provided fields will be updated.

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
Reset a chat workspace’s settings to its default values.

Path parameters

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
Create a chat completions stream using Meilisearch’s OpenAI-compatible interface. This endpoint searches relevant indexes and generates responses based on the retrieved content.

Path parameters

Request body

Meilisearch chat completions only supports streaming responses (stream: true).

Message object

role

Specifies the message origin: Meilisearch (system), the LLM provider (assistant), or user input (user)

content

String containing the message content.

Response

The response follows the OpenAI chat completions format. For streaming responses, the endpoint returns Server-Sent Events (SSE).

Streaming response example

Example