--- title: Meilisearch CLI quick start sidebarTitle: CLI description: Install meili, start a free Meilisearch Cloud trial with meili trial start, then add and search documents from your terminal or an AI coding agent. --- This guide walks you through setting up Meilisearch with `meili`, the Meilisearch command line tool. `meili` works with Meilisearch Cloud projects and with self-hosted instances. ## Prerequisites - A command-line terminal. You do not need a Meilisearch account or project: `meili trial start` creates both. To use a self-hosted instance instead, [run Meilisearch locally](/resources/self_hosting/getting_started/quick_start) - Node.js 22 or later, only if you install the CLI with npm ## 1. Install the CLI ```bash npm install -g @meilisearch/cli ``` ```bash brew install meilisearch/tap/meili # to upgrade brew update && brew upgrade meilisearch/tap/meili ``` ```bash curl -fsSL https://raw.githubusercontent.com/meilisearch/cli/main/scripts/install.sh | sh ``` The script works on macOS and Linux. Run it again to update the CLI. Check the installation: ```bash meili version ``` ## 2. Connect to Meilisearch The CLI stores your projects in a config file, `~/.config/meili/config.json` by default. Each project has a name, a URL, and an API key. Start a free trial project: ```bash meili trial start ``` The command opens your browser to log in, or to create your Meilisearch Cloud account. It then creates a free trial project, waits until the project is running, and adds it to your config file with its master key. It asks no questions. Run it again and it returns the same project. See the [pricing page](https://www.meilisearch.com/pricing) for the trial terms. By default, the project takes the name of the current directory and runs in the closest region that offers a free trial. Change these with `--name` and `--region-id`. If your account belongs to several teams, give `--team-id`. The command prints the name of the project in the config file and a link to the project in the dashboard. Use the name with `--project` in the next steps, or open the dashboard link to work with the project in your browser. Log in to Meilisearch Cloud in your browser, then add your Cloud projects to the config file: ```bash meili auth login meili config sync-with-cloud --all ``` When you are an admin of the project's team, the CLI also saves the project's master key. Otherwise, the CLI saves the project without an API key. Ask an admin of the team for an API key, then add it to the config file: ```bash meili config update --project PROJECT_NAME --project-api-key YOUR_API_KEY ``` Add your instance to the config file: ```bash meili config set --project local \ --project-url http://localhost:7700 \ --project-api-key YOUR_API_KEY ``` List the projects of the config file: ```bash meili config list ``` Every command takes the project name with `--project` (or `-p`). In the next steps, replace `PROJECT_NAME` with the name of your project. Check that the project is available: ```bash meili health --project PROJECT_NAME # status available ``` ## 3. Add documents Create a `movies.json` file: ```bash cat > movies.json << 'EOF' [ { "id": 1, "title": "The Matrix", "genres": ["Action", "Sci-Fi"], "year": 1999 }, { "id": 2, "title": "Inception", "genres": ["Action", "Thriller"], "year": 2010 }, { "id": 3, "title": "Interstellar", "genres": ["Drama", "Sci-Fi"], "year": 2014 } ] EOF ``` Add the documents to the `movies` index (`--index` or `-i`): ```bash meili document add --project PROJECT_NAME --index movies --file movies.json --wait ``` Meilisearch creates the `movies` index if it does not exist. Adding documents is an [asynchronous operation](/capabilities/indexing/tasks_and_batches/async_operations): without `--wait`, the CLI prints the task and returns at once. `--wait` follows the task until indexing is complete, then prints the final task. ## 4. Search ```bash meili search --project PROJECT_NAME --index movies --q matrix ``` The CLI prints the results as a table: ```text Showing 1 of about 1 query matrix • processingTimeMs 1 • limit 20 • offset 0 ID TITLE GENRES YEAR 1 The Matrix Action, Sci-Fi 1999 ``` Add `--json` to print the JSON response of Meilisearch instead. ## 5. Search with filters First, configure filterable attributes: ```bash meili settings update --project PROJECT_NAME --index movies \ --filterable-attributes genres,year --wait ``` Then search with filters: ```bash meili search --project PROJECT_NAME --index movies \ --filter 'genres = "Sci-Fi" AND year > 2000' ``` Without `--q`, Meilisearch runs a placeholder search and returns all documents that match the filter, here `Interstellar`. ## Full example ```bash # Create a free trial project, and note the project name it prints meili trial start # Add documents meili document add -p PROJECT_NAME -i movies --file movies.json --wait # Search meili search -p PROJECT_NAME -i movies --q inter ``` ## Start a trial from an AI agent `meili trial start` asks no questions, so an AI coding agent can run it for you: - The command writes the login URL to stderr. The agent shows it to you, and you approve it in your browser. With `--no-login`, the command fails instead of opening a browser when nobody is logged in. - The command writes one JSON object to stdout, with the fields `created`, `configProject`, `dashboardUrl`, and `project`. The output never contains the master key, which stays in the config file. - Running the command again is safe. When the account already has an active free trial project, the command creates nothing and returns that project with `"created": false`. - When the account belongs to several teams, the command fails and lists them. Run it again with `--team-id`. The agent then passes the `configProject` value to `--project` in the other commands. ## Move a self-hosted instance to Meilisearch Cloud Move your self-hosted instance, local or in production, to Meilisearch Cloud in one CLI command: ```bash meili teleport ``` The command creates your Cloud account if needed, creates the project, and sends your data to it. Unlike `meili trial start`, it asks questions in the terminal, so you run it yourself. See [Migrating to Meilisearch Cloud](/resources/migration/migrating_cloud). ## Explore the commands `meili --help` lists every command. Add `--help` to any command to see its flags and examples: ```bash meili --help meili search --help ``` `meili schema` describes every command as JSON. `meili schema --command ` describes one command in full, with its flags, the Meilisearch routes it calls, and examples. Scripts and AI agents can use it to discover the commands: ```bash meili schema meili schema --command search ``` ## Next steps Move a self-hosted instance with `meili teleport` Explore all search parameters ## Resources - [Meilisearch CLI on GitHub](https://github.com/meilisearch/cli)