Skip to main content
One-shot summarization uses the same /chats API as multi-turn chat, but with a different prompt strategy: instead of building a conversation, you send a single question and receive a summarized answer based on your indexed documents. This is useful for displaying AI-generated answers alongside traditional search results. Make sure you have completed the setup guide before continuing.
In code examples, replace WORKSPACE_NAME with the name of your workspace. On Meilisearch Cloud, the default workspace name is cloud.
All requests to the chat completions endpoint must include "stream": true. Non-streaming (stream: false) is not yet supported and returns a 501 Not Implemented error.

Configure your workspace prompt for summarization

The key difference from a chat interface is the system prompt. For summarization, instruct the model to produce concise, self-contained answers and avoid follow-up questions:
curl \
  -X PATCH 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \
  -H 'Authorization: Bearer MEILISEARCH_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "prompts": {
      "system": "You are a search assistant. When the user asks a question, provide a single concise answer based only on the search results. Keep your response to 2-3 sentences maximum. Do not ask follow-up questions. Do not use your general knowledge. If the search results do not contain enough information, say so briefly."
    }
  }'
Key differences from a multi-turn chat prompt:
  • The system prompt explicitly asks for short, self-contained answers
  • The model is told not to ask follow-up questions
  • Responses are limited to a few sentences
Since the system prompt controls the answer style, we recommend creating a dedicated workspace for summarization rather than reusing a chat workspace. This keeps the prompts separate and avoids affecting other use cases. On Meilisearch Cloud, if you need a second workspace, contact our support team.

Send a single question

Send a request to the chat completions endpoint. The difference from multi-turn chat is that you only send one message and do not maintain conversation history:
curl -N \
  -X POST 'MEILISEARCH_URL/chats/WORKSPACE_NAME/chat/completions' \
  -H 'Authorization: Bearer MEILISEARCH_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "model": "PROVIDER_MODEL_UID",
    "stream": true,
    "messages": [
      {
        "role": "user",
        "content": "What is the return policy for electronics?"
      }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "_meiliSearchSources",
          "description": "Provides sources of the search",
          "parameters": {
            "type": "object",
            "properties": {
              "call_id": { "type": "string", "description": "The call ID to track the original search" },
              "documents": { "type": "array", "items": { "type": "object" }, "description": "The documents associated with the search" }
            },
            "required": ["call_id", "documents"],
            "additionalProperties": false
          },
          "strict": true
        }
      }
    ]
  }'
Including the _meiliSearchSources tool lets you display the source documents alongside the summarized answer, so users can verify the information. In a real application, you would run this in parallel with a standard Meilisearch search request and display both results together. For summarization, you may want to use a lower temperature value (for example, 0.1 or 0.2) to produce more deterministic, factual answers. Meilisearch passes these parameters through to your LLM provider.

Next steps

Build a chat interface

Create a multi-turn conversational interface with follow-up questions.

Display source documents

Show users which documents were used to generate the summary.

Configure guardrails

Restrict AI responses to topics covered by your data.

Reduce hallucination

Learn techniques to improve accuracy of AI-generated answers.

Chat completions API reference

Full reference for the chat completions endpoint.