Skip to main content
Conversational search involves multiple systems (Meilisearch, an LLM provider, your application). Any of these can fail. This guide covers common failure modes and how to handle them gracefully.

Common error scenarios

Handle LLM provider errors

When the LLM provider is unavailable or returns an error, the chat completions endpoint forwards the error. Wrap your requests in error handling to provide a fallback:
When conversational search fails, you can fall back to a standard keyword or hybrid search. This ensures users still get results:

Handle empty search results

When the LLM cannot find relevant documents, it may hallucinate an answer or give a vague response. Use guardrails in your system prompt to handle this:
You can also detect empty results on the client side by inspecting the _meiliSearchSources tool call. If the sources array is empty, display a helpful message:

Handle rate limiting

LLM providers enforce rate limits based on requests per minute or tokens per minute. When you hit these limits, implement backoff:
To reduce rate limiting in production:
  • Use a higher-tier API key with your LLM provider
  • Implement client-side debouncing to avoid sending requests on every keystroke
  • Cache responses for repeated questions

Manage context window limits

Long conversations can exceed the LLM’s context window. When this happens, the provider returns an error. Trim older messages from the conversation history to stay within limits:

Display errors in your UI

When an error occurs, give users clear feedback and actionable next steps. Avoid exposing raw error messages or stack traces:

Next steps

Configure guardrails

Reduce hallucination with system prompts

Stream chat responses

Implement real-time streaming for chat responses