Learning resourcesReviewed · Mistral AI

Mistral quickstart: find the closest text with embeddings

A short official Mistral tutorial for beginners and developers that shows how to turn sentences into embeddings and find the one closest in meaning to a question; the main catch is that it is a three-sentence toy demo that needs a Mistral API key and says nothing about pricing. The Python script calls the mistral-embed model through the mistralai SDK, then ranks the documents by cosine similarity.

Researched 14 Nov 2026

In short.

This is a short official Mistral quickstart for beginners and developers that teaches text embeddings and semantic matching with a hosted API; its main catch is that it is a three-document toy example that needs a Mistral API key and gives no pricing or licence information. The page walks through creating a uv project, installing the mistralai SDK, exporting MISTRAL_API_KEY, and running one Python script. The script embeds three short documents and one question in a single call to the mistral-embed model, computes cosine similarity in plain Python, and prints the closest document. The page says the refund-policy sentence wins for the question 'Can I get my money back?' although the question never uses the word refund. Nothing was run for this report. The code, the sample scores and the 5-minute estimate are the page's own claims, not verified results.

Researched and written by an AI model and checked by a second AI model. How it works

The scope was the complete selected documentation page at [https://docs.mistral.ai/inference/quickstarts/create-embeddings.md], captured as one file (selected-page.txt, 3,452 bytes). Pages it links to are excluded: the Embeddings reference, the API key guide, the library quickstart, the RAG quickstart and the uv installation page. No licence, pricing, changelog or SDK evidence was captured, so costs, rights, model dimensions and SDK compatibility are unknown. Nothing was executed. The script, the sample scores and the 5-minute estimate are the page's own claims and were not verified.

The overview

What this resource is

This is a documentation page titled 'Quickstart: find the closest text with embeddings' on Mistral's docs site at [https://docs.mistral.ai/inference/quickstarts/create-embeddings.md]. It is a hands-on tutorial in the inference quickstarts section. Its own description says it will 'turn sentences into embeddings and find the one closest in meaning to a question, in about 5 minutes.'

The page does not name an author, version or publication date. The only product identifiers it gives are the SDK package name (mistralai), the Python import (from mistralai.client import Mistral) and the model name (mistral-embed).

Overall assessment

On the page's evidence alone, this is a clear, compact first lesson in semantic matching. It has prerequisites, setup commands, a complete script, a run command and expected output. It shows the main idea of embeddings: text with similar meaning gets similar vectors, even without shared keywords.

It is deliberately minimal. It does not cover chunking, storing vectors, large collections, error handling, or choosing between models. The example sends four inputs in one request; batch-size limits and larger-scale batching strategies are not documented. It also does not cover cost. Treat it as an entry point, not a production pattern. Nothing was executed for this assessment, so the script's behaviour and the sample output are unverified.

Who it is for

It suits people who are new to embeddings and want a first working example. It also suits developers who already use Python and want to see the shape of Mistral's embeddings call. The explanation is light: it assumes you can run shell commands and read a short Python script, but it does not require prior knowledge of vectors.

It is less useful for people who need guidance on production retrieval, vector databases, evaluation of retrieval quality, or comparing embedding providers. The page points to other Mistral quickstarts for a library and for a RAG pipeline, but those pages are outside the selected scope and were not reviewed.

What you can learn to do

The tutorial shows how to create embeddings for several texts with one call: client.embeddings.create(model='mistral-embed', inputs=documents + [question]). The script embeds three documents and a question in a single request. It reads each result from response.data as item.embedding, which is a list of floats.

It then shows how to compare vectors with a hand-written cosine similarity function, print a score per document, and pick the highest-scoring one with max(). The claimed outcome is that the refund-policy sentence ranks first for 'Can I get my money back?', because the model captures meaning rather than matching words.

The page does not state the vector dimension, input length limits, batch size limits or supported languages. It defers 'models and dimensions' to a separate Embeddings page, which is not part of the selected scope.

Using it

Requirements

The page lists two prerequisites: a Mistral API key, and Python 3.10 or later with uv installed. It links to separate pages for creating an API key and installing uv, and neither was reviewed. The setup also needs network access to the Mistral API, which follows from the script calling the hosted client. The page does not say this directly.

It does not say whether an API key needs a paid plan, whether free usage is available, or what rate limits apply. Those details are unknown from this evidence. The setup uses a Python 3.12 project, which satisfies the stated minimum of 3.10.

How it works

The script creates a Mistral client from the MISTRAL_API_KEY environment variable. It builds one list of inputs: the three documents followed by the question. It sends that list to the embeddings endpoint through the SDK and collects the returned vectors in the same order. The last vector is the question's vector.

The cosine function computes the dot product of two vectors divided by the product of their lengths, using only Python's math module and built-in sum and zip. Each document vector is scored against the question vector. The script prints each score and the document with the highest score.

Since the matching is done locally with plain Python, no vector database or numerical library is needed for this demo. The embedding step itself happens on Mistral's hosted API, so the texts are sent to that service. The page does not describe data retention or privacy terms.

Setup steps

The page gives three shell commands: uv init embeddings --python 3.12 && cd embeddings, then uv add mistralai, then export MISTRAL_API_KEY='your-api-key'. After that you create embeddings.py with the supplied script and run it with uv run embeddings.py.

The command specifies no SDK version; the installed version and its compatibility are not established by this page. The script uses the import path from mistralai.client import Mistral. Whether that path works with every released SDK version is not established by the page, and it was not checked. If you hit an import error, check the SDK version and the SDK documentation.

Worked example

The documents are: support hours (Monday to Friday, 9:00 to 18:00 CET), an annual-plan refund policy (30 days), and an API rate limit note. The question is 'Can I get my money back?'

The page shows this expected output: 0.675 for the support-hours sentence, 0.722 for the refund sentence and 0.616 for the rate-limit sentence, followed by 'Closest document: Annual plans can be refunded within 30 days of purchase.' The page says exact scores vary with the model version and that the order is what matters.

These numbers come from the page and were not reproduced here. They also show that the scores sit close together: the winner leads the runner-up by about 0.05. In a real application you would need to check how well the ranking holds up on your own data, and the page does not cover that.

Assessment & evidence

Limitations and risks

The example is tiny: three documents and one question. It shows the idea but not how embeddings behave on realistic data, long texts, many languages or noisy input. The sample scores are close together (0.616 to 0.722), and the page does not discuss thresholds, ranking errors or evaluation.

The script scores documents in a Python loop; performance on larger collections is unknown. The page gives no guidance on vector stores, chunking, retries, rate limits or errors. The example sends four inputs in one request; batch-size limits and larger-scale batching strategies are not documented. It does not state the embedding dimension, the input limit or the supported languages. It relies on a hosted API, so the text you embed leaves your machine, and the page says nothing about data handling. The script requires an API key kept in an environment variable. The page shows a placeholder and does not discuss key safety beyond that.

Nothing was run for this report, so every behaviour here is as claimed by the page.

Why this assessment

The assessment rests on what the page says and shows. The page is complete for its stated purpose: it names its prerequisites, gives exact commands, gives a full runnable-looking script, and shows the output you should expect. The code is short enough to read in full, and it makes one API call and does local arithmetic. Nothing in the page shows code that does anything other than what the tutorial describes.

Claims about speed ('about 5 minutes'), the expected scores and the ranking come from the page, not from any run, so they are reported as the page's claims. Cost, rights, data handling, model details and SDK compatibility are marked unknown because the page does not establish them.

Alternatives and next steps

The page itself points to three follow-ups: the Embeddings reference page for models and dimensions, a quickstart on creating a library and asking it a question, and a quickstart on building a RAG pipeline. Those linked pages were outside the selected scope and were not reviewed.

The evidence contains no comparison with other embedding services, tools or approaches, so this report makes no claim about relative quality, cost or ease.

Evidence base

This report is based on one captured file: the selected documentation page at [https://docs.mistral.ai/inference/quickstarts/create-embeddings.md] (3,452 bytes, captured 2026-11-14). The page was read in full. It contains the prerequisites, setup commands, the Python script, the run command, the expected output and a list of follow-up links.

There is no repository, changelog, licence file, pricing page or SDK documentation in the evidence. Link targets inside the page were not fetched.

Access & freshness

Costs

The page states no prices, free-tier terms, quotas or per-token charges for the embeddings API, so the cost of running the example is unknown from this evidence. uv is a prerequisite you are expected to have installed already, and the page then uses uv to install the mistralai SDK. The page does not describe the licences or costs of either. The tutorial's single request embeds four short strings, but the page does not say what that costs or whether it falls inside any free allowance. Check Mistral's pricing information before relying on it.

Rights and reuse

The captured page carries no licence statement, copyright notice or reuse terms, so the rights to copy, adapt or redistribute the text or the code snippet are unknown from this evidence. The script is a short demo shown for readers to use in a tutorial, but the page does not grant a licence. Do not treat it as openly licensed. Use of the Mistral API itself is governed by terms that this page does not describe. No distribution file is offered for this resource.

Freshness

The page was captured on 2026-11-14. It shows no publication date, last-updated date or version number. The only version hint is the note that exact scores vary with the model version. It does not say which mistral-embed version produced the sample numbers. Because the SDK is installed without a pinned version, the SDK, and the page's import path, may drift apart over time. This evidence cannot say whether that has happened.

Suggested next actions

Before starting, create a Mistral API key and check Mistral's current pricing and free-usage terms, since this page does not give them. Then follow the setup in order, run the script, and compare your output with the page's expected ordering. Do not expect identical scores.

If the import fails, check the installed mistralai version against the SDK documentation. Once the basic example works, try your own short texts and questions to see how close the scores are. Then read the linked Embeddings reference, which the page says covers models and dimensions; whether it also covers input limits is unknown from this evidence. If you take the approach beyond this demo, consider whether your use case needs chunking, vector storage or a way to evaluate retrieval quality, since the page does not address these. Review data-handling terms before sending private text to the API.

Evidence for this report

selected-page.txtselected · checked 2026-11-14