Skip to main content

llm-mistral

PyPI Changelog Tests License

LLM plugin providing access to Mistral models using the Mistral API

Installation

Install this plugin in the same environment as LLM:

llm install llm-mistral

Usage

First, obtain an API key for the Mistral API.

Configure the key using the llm keys set mistral command:

llm keys set mistral
<paste key here>

You can now access the Mistral hosted models. Run llm models for a list.

To run a prompt through mistral-tiny:

llm -m mistral-tiny 'A sassy name for a pet sasquatch'

To start an interactive chat session with mistral-small:

llm chat -m mistral-small
Chatting with mistral-small
Type 'exit' or 'quit' to exit
Type '!multi' to enter multiple lines, then '!end' to finish
> three proud names for a pet walrus
1. "Nanuq," the Inuit word for walrus, which symbolizes strength and resilience.
2. "Sir Tuskalot," a playful and regal name that highlights the walrus' distinctive tusks.
3. "Glacier," a name that reflects the walrus' icy Arctic habitat and majestic presence.

To use a system prompt with mistral-medium to explain some code:

cat example.py | llm -m mistral-medium -s 'explain this code'

Vision

The Pixtral models are capable of interpreting images. You can use those like this:

llm -m pixtral-large 'describe this image' \
  -a https://static.simonwillison.net/static/2025/two-pelicans.jpg

Output:

This image features two pelicans in flight against a clear blue sky. Pelicans are large water birds known for their long beaks and distinctive throat pouches, which they use for catching fish. In this photo, the birds are flying close to each other, showcasing their expansive wings and characteristic beaks. The clear sky provides a stark contrast, highlighting the details of their feathers and the graceful curves of their wings. The image captures a moment of synchronicity and elegance in nature.

You can pass filenames instead of URLs.

Audio

The Voxtral models - voxtral-small and voxtral-mini - are capable of accepting audio input. You can pass either a local MP3 file or a URL to one:

llm -m voxtral-small \
  -a https://static.simonwillison.net/static/2024/pelican-joke-request.mp3

Output:

What do you call a pelican with no teeth? A gum-ican

Tools

To see a list of Mistral models that support tools (most of them) run:

llm models --tools -q mistral

Try one out like this:

llm -m mistral-medium -T llm_time 'What time is it?' --td

Schemas

Mistral models (with the exception of codestral-mamba) also support schemas:

llm -m mistral-small --schema 'name,bio:one sentence' 'invent a cool dog'

Output:

{
  "name": "CyberHound",
  "bio": "A futuristic dog with glowing cybernetic enhancements and the ability to hack into any system."
}

Reasoning

For models that support reasoning, set the effort using -o reasoning_effort:

llm -m magistral-small 'What is the next number in 2, 6, 12, 20?' -o reasoning_effort high

The Mistral API defines none, minimal, low, medium, high and xhigh. Supported levels depend on the model. If you omit this option, the model's default applies.

When streaming (the default), reasoning text is displayed on stderr, separate from the answer on stdout. Use -R or --hide-reasoning to hide it:

llm -m magistral-small 'Solve this puzzle...' -o reasoning_effort high -R

Hiding reasoning only changes its display; use -o reasoning_effort none to disable reasoning on models that support that level. LLM's CLI also prints only the answer with --no-stream. In Python, response.text() returns only the answer, while response.messages() includes ReasoningPart objects. Reasoning blocks and their signatures are preserved when continuing a conversation, with both streaming and non-streaming responses and with the synchronous and asynchronous APIs.

Model options

Options are passed using -o name value syntax. Availability depends on the model:

  • -o reasoning_effort high: Reasoning effort: none, minimal, low, medium, high or xhigh.
  • -o temperature 0.7: The sampling temperature, between 0 and 1. Higher increases randomness, lower values are more focused and deterministic.
  • -o top_p 0.1: 0.1 means consider only tokens in the top 10% probability mass. Use this or temperature but not both.
  • -o max_tokens 20: Maximum number of tokens to generate in the completion.
  • -o safe_prompt 1: Injects Mistral's safety prompt before the conversation. This replaces the removed safe_mode option; update existing commands to use safe_prompt.
  • -o random_seed 123: Set an integer random seed to generate deterministic results.
  • -o prefix 'Prefix here: Set a prefix that will be used for the start of the response. Try { to encourage JSON or GlaDOS: to encourage a roleplay from a specific character.

Available models

Run llm models for a full list of Mistral models. This plugin configures the following alias shortcuts:

  • mistral-tiny for mistral/mistral-tiny
  • mistral-nemo for mistral/open-mistral-nemo
  • mistral-small-2312 for mistral/mistral-small-2312
  • mistral-small-2402 for mistral/mistral-small-2402
  • mistral-small-2409 for mistral/mistral-small-2409
  • mistral-small-2501 for mistral/mistral-small-2501
  • magistral-small-2506 for mistral/magistral-small-2506
  • magistral-small for mistral/magistral-small-latest
  • mistral-small for mistral/mistral-small-latest
  • mistral-medium-2312 for mistral/mistral-medium-2312
  • mistral-medium-2505 for mistral/mistral-medium-2505
  • magistral-medium-2506 for mistral/magistral-medium-2506
  • magistral-medium for mistral/magistral-medium-latest
  • mistral-medium for mistral/mistral-medium-latest
  • mistral-large for mistral/mistral-large-latest
  • codestral-mamba for mistral/codestral-mamba-latest
  • codestral for mistral/codestral-latest
  • ministral-3b for mistral/ministral-3b-latest
  • ministral-8b for mistral/ministral-8b-latest
  • pixtral-12b for mistral/pixtral-12b-latest
  • pixtral-large for mistral/pixtral-large-latest
  • devstral-small for mistral/devstral-small-latest
  • voxtral-mini for mistral/voxtral-mini-2507
  • voxtral-small for mistral/voxtral-small-2507

Refreshing the model list

Mistral sometimes release new models.

To make those models available to an existing installation of llm-mistral run this command:

llm mistral refresh

This will fetch and cache the latest list of available models. They should then become available in the output of the llm models command.

Embeddings

The Mistral Embeddings API can be used to generate 1,024 dimensional embeddings for any text.

To embed a single string:

llm embed -m mistral-embed -c 'this is text'

This will return a JSON array of 1,024 floating point numbers.

Mistral's Codestral Embed is an embedding model that specializes in code. LLM supports that in four different sizes:

llm embed -m mistral/codestral-embed-256 -c 'code...'
llm embed -m mistral/codestral-embed-512 -c 'code...'
llm embed -m mistral/codestral-embed-1024 -c 'code...'
llm embed -m mistral/codestral-embed-1536 -c 'code...'
llm embed -m mistral/codestral-embed-3072 -c 'code...'

The number is the size of the vector that will be returned.

You can also use codestral-embed which is an alias for the default size, codestral-embed-1536.

The [LLM documentation](https://llm.datasette.io/en/stable/embeddings/index.html) has more, including how to embed in bulk and store the results in a SQLite database.

See [LLM now provides tools for working with embeddings](https://simonwillison.net/2023/Sep/4/llm-embeddings/) and [Embeddings: What they are and why they matter](https://simonwillison.net/2023/Oct/23/embeddings/) for more about embeddings.

## Development

To set up this plugin locally, first checkout the code and run the tests with `uv`:
```bash
cd llm-mistral
uv run pytest

To run llm against the development version of the plugin:

uv run llm -m mistral-small hi

Metadata

Release files for llm-mistral 0.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-mistral 0.16
File Size Uploaded
llm_mistral-0.16.tar.gz 23.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-mistral 0.16
File Interpreter ABI Platform
llm_mistral-0.16-py3-none-any.whl Python 3 none any Details

Total release size: 39.7 kB

Release files / llm_mistral-0.16.tar.gz

Download URL llm_mistral-0.16.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2314ca566b0ffc15cb9e17ec37b50d9267271219a041b097f0a5e95ddc31107c
BLAKE2b-256 checksum
How to use checksums
aea91a4ea5fe42bd06b2b59a9e7a11f8306638a4f1c6ffc78abc55ebc1267093
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / llm_mistral-0.16-py3-none-any.whl

Download URL llm_mistral-0.16-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
084f01467bb369b8ced1392ce3794277f21881dcc63a1c374354ac9e55b89e69
BLAKE2b-256 checksum
How to use checksums
84c6d956826948219c9b40b4f8e8f514c083100c110158fa5ad6148e9e5d9808
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.16 This release

2 release files

0.15

2 release files

0.14

2 release files

0.13

2 release files

0.12

2 release files

0.11

2 release files

0.10

2 release files

0.9

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3.1

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page