Skip to main content
@meilisearch/ai-sdk adds Meilisearch search tools to the Vercel AI SDK, letting an LLM decide when to search your data and how to use the results.

Requirements

  • A Meilisearch project with at least one index containing documents
  • A search API key for that project
  • An API key from an LLM provider (this example uses OpenAI, but any provider supported by the AI SDK works)

Install

Add your credentials to your environment:
.env

Give an agent a search tool

The model decides whether and how many times to call search before answering. The description field tells it what the index contains and when to use it.

AI SDK demo

Next.js chatbox example application

Going further

Getting started with agentic search

Build a multi-turn chatbot with streaming responses.

Display source documents

Show users which documents an agent used to answer.

Configure guardrails

Keep agents on topic and grounded in your data.

Handle errors and fallbacks

Make your agent resilient to search and LLM failures.
For the full list of available tools, see the SDK repository. If you need natural-language admin access instead of an app-embedded agent, see the MCP integration.