> ## Documentation Index
> Fetch the complete documentation index at: https://www.meilisearch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic movie search

> Movie recommendation agent built with @meilisearch/ai-sdk and the Vercel AI SDK

<Info>
  **Live demo**: [what2watch.meilisearch.com](https://what2watch.meilisearch.com)
</Info>

This demo is a movie recommendation chatbot built with [`@meilisearch/ai-sdk`](/docs/getting_started/integrations/ai_sdk) and the [Vercel AI SDK](https://ai-sdk.dev). Describe the evening you have in mind, and the agent decides which searches to run against the movies index before recommending anything.

<img src="https://mintcdn.com/meilisearch-6b28dec2/RaMAjZ3OsZEW_QfK/assets/images/demos/agentic-movie-search-demo.png?fit=max&auto=format&n=RaMAjZ3OsZEW_QfK&q=85&s=cd5a915aa5fc7cdc8dd10e81358bd83f" alt="The agentic movie search demo running two searches and recommending auteur films" width="1312" height="1800" data-path="assets/images/demos/agentic-movie-search-demo.png" />

## Key features

* **Agent-driven queries**: The model writes its own search queries instead of searching for the user's words. Asking for "films d'auteur, nothing boring" leads it to search for "auteur art house drama" and "Quentin Tarantino". This is the core idea behind [agentic search](/docs/capabilities/agentic_search/overview).
* **Multiple searches per question**: The agent keeps searching until it has enough material to answer, running up to five steps per turn to cover different angles.
* **Two search tools**: `meilisearchSearch` looks up movies by title or description, and `meilisearchSearchSimilar` finds related titles through the [`/similar` endpoint](/docs/capabilities/personalization/getting_started/recommendations) from a movie the user already likes.
* **Hybrid search under the hood**: The search tool is configured with [hybrid search](/docs/capabilities/hybrid_search/overview) and a [`semanticRatio`](/docs/capabilities/hybrid_search/advanced/custom_hybrid_ranking#understanding-semanticratio) of 0.5, so queries such as "art house" match on meaning as well as on keywords.
* **Visible search steps**: Every search appears above the answer as "20 results found for ...". Expand any step to see the exact documents Meilisearch returned, which is the same idea as [displaying source documents](/docs/capabilities/agentic_search/how_to/display_source_documents) in your own agent.
* **Rich results**: The model interleaves prose with movie blocks, which the interface renders as cards with posters and release years instead of a plain list of titles.
* **Conversational refinement**: Follow-up messages keep the context, and the agent suggests ways to narrow down, such as choosing between more cerebral and more kinetic picks. Its behavior is steered by a system prompt, as described in [optimize chat prompts](/docs/capabilities/agentic_search/how_to/optimize_chat_prompts).
* **Genre shortcuts**: The home screen offers 12 genres for visitors who would rather browse than describe what they want.

## Example conversation

1. **"A friend is coming over tonight and he loves films d'auteur. What would you recommend? Nothing boring please."** The agent searches for "auteur art house drama" and "Quentin Tarantino", then recommends Pulp Fiction, Django Unchained, and Inglourious Basterds, explaining why each one fits.
2. **"Something more cerebral"** Runs a new search and moves toward Kubrick and slower-burn titles, keeping the earlier constraints in mind.

## How it works

The application is a Next.js app. Its chat route gives Claude Sonnet 4.5 two Meilisearch tools and lets the model decide when to call them:

```ts theme={null}
import { meilisearchSearch, meilisearchSearchSimilar } from "@meilisearch/ai-sdk";

const meilisearch = {
  host: process.env.MEILISEARCH_HOST,
  apiKey: process.env.MEILISEARCH_SEARCH_API_KEY,
  indexUid: process.env.MEILISEARCH_INDEX,
};

const tools = {
  searchMovies: meilisearchSearch({
    ...meilisearch,
    description: "Search movies by title or description",
    searchParams: {
      hybrid: { embedder: "small", semanticRatio: 0.5 },
    },
  }),
  searchSimilarMovies: meilisearchSearchSimilar({
    ...meilisearch,
    description: "Find similar movies by document ID",
    searchSimilarParams: { embedder: "small", limit: 10 },
  }),
};
```

Both tools use an [embedder](/docs/capabilities/hybrid_search/how_to/choose_an_embedder) named `small` and a [search API key](/docs/capabilities/security/how_to/manage_api_keys) scoped to the movies index. Responses stream back with `streamText`. The `stopWhen: stepCountIs(5)` option stops the tool-calling loop after five model steps, which is what limits how many searches the agent can chain together. Reaching that limit ends the loop, so it does not by itself guarantee a final answer. The movies dataset is public, so you can clone the repository and run the same demo locally.

To build the same thing step by step with your own data, follow the [agentic search getting started guide](/docs/capabilities/agentic_search/getting_started).

## Links

<CardGroup cols={2}>
  <Card title="Try the demo" icon="globe" href="https://what2watch.meilisearch.com">
    Ask for a recommendation and watch the agent search
  </Card>

  <Card title="Source code" icon="github" href="https://github.com/meilisearch/ai-sdk-demo">
    Next.js application on GitHub
  </Card>

  <Card title="AI SDK integration" icon="plug" href="/docs/getting_started/integrations/ai_sdk">
    Give your own agent a Meilisearch search tool
  </Card>

  <Card title="Agentic search" icon="robot" href="/docs/capabilities/agentic_search/overview">
    Learn how agentic search works with Meilisearch
  </Card>
</CardGroup>

<Tip>
  Looking for classic search on the same kind of movie data? See the [Where to Watch demo](/docs/resources/demos/where_to_watch), which showcases hybrid search, recommendations, and custom ranking rules.
</Tip>
