mistralM

Docs

Vision

Envoyez des images à des modèles dotés de capacités de vision via la Chat Completions API et analysez du contenu visuel en plus du texte.

Les capacités de vision permettent aux modèles d’analyser des images et de fournir des informations basées sur le contenu visuel, en plus du texte. Cette approche multimodale ouvre de nouvelles possibilités pour les applications qui nécessitent une compréhension à la fois textuelle et visuelle.

Nous proposons plusieurs modèles dotés de capacités de vision, tous disponibles via la Chat Completions API.

lightbulb

Pour l’analyse de documents, l’OCR et l’extraction de données, consultez Document AI.

Avant de commencer

Modèles recommandés avec capacités de vision

  • Mistral Large 4 via mistral-large-4-0
  • Mistral Large 3 via mistral-large-2512
  • Mistral Medium 3.1 via mistral-medium-2508
  • Mistral Small 3.2 via mistral-small-2506
  • Ministral 3 :
    • Ministral 3 14B via ministral-14b-2512
    • Ministral 3 8B via ministral-8b-2512
    • Ministral 3 3B via ministral-3b-2512

Envoyer une image

Utiliser les modèles de vision

Il existe deux façons d’envoyer une image à la Chat Completions API : en transmettant une URL ou en transmettant une image encodée en base64.

lightbulb

Avant de continuer, nous vous recommandons de lire la documentation Chat Completions pour en savoir plus sur l’API chat completions et son utilisation.

Si l’image est hébergée en ligne, vous pouvez simplement fournir l’URL publiquement accessible de l’image dans la requête. Cette méthode est simple et ne nécessite aucun encodage.

import os
from mistralai import Mistral

api_key = os.environ["MISTRAL_API_KEY"]
model = "mistral-small-latest"

client = Mistral(api_key=api_key)

messages = [
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "What's in this image?"
            },
            {
                "type": "image_url",
                "image_url": "/images/eiffel-tower-paris.jpg"
            }
        ]
    }
]

chat_response = client.chat.complete(
    model=model,
    messages=messages
)
Sortie
{
    "id": "a8251fb1c4a64014b80141bd5685f6c7",
    "created": 1756318369,
    "model": "mistral-small-latest",
    "usage": {
    "prompt_tokens": 2099,
    "total_tokens": 2235,
    "completion_tokens": 136
    },
    "object": "chat.completion",
    "choices": [
    {
        "index": 0,
        "finish_reason": "stop",
        "message": {
        "role": "assistant",
        "tool_calls": null,
        "content": "The image depicts the Eiffel Tower, an iconic landmark located in Paris, France. The photograph is taken from a low angle, looking up towards the sky, emphasizing the tower's impressive height and intricate iron lattice structure. The Eiffel Tower is composed of three main levels, each offering viewing platforms for visitors. The sky is clear and blue, providing a striking contrast to the brownish hue of the iron tower. The base of the tower is framed by trees, adding a touch of natural greenery to the scene. In the background, beyond the tower, some buildings are visible, indicating the urban setting of the Eiffel Tower in the heart of Paris."
        }
    }
    ]
}

Cas d’usage

Vous trouverez ci-dessous quelques exemples de cas d’usage tirant parti des capacités de vision de nos modèles : de la compréhension de graphiques à l’extraction de données, les cas d’usage sont variés.

pen

Ce sont des exemples simples dont vous pouvez vous inspirer pour créer vos propres cas d’usage. Pour l’OCR et les sorties structurées, consultez Document AI.

curl https://api.mistral.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MISTRAL_API_KEY" \
  -d '{
    "model": "ministral-14b-latest",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What’s in this image?"
          },
          {
            "type": "image_url",
            "image_url": "https://cdn.statcdn.com/Infographic/images/normal/30322.jpeg"
          }
        ]
      }
    ],
    "max_tokens": 300
  }'
Sortie
The chart is a bar chart titled 'France's Social Divide,' comparing socio-economic indicators between disadvantaged areas and the whole of France. It comprises two sections: the first section includes three bar groups representing the percentage of people part of the working-class, unemployment rate, and percentage of 16-25-year-olds not in school and unemployed. The second section includes three bar groups representing median monthly income, poverty rate, and households living in overcrowded housing. Each bar group contains two bars: one for disadvantaged areas (red) and one for the whole of France (blue). The data indicate that disadvantaged areas have higher percentages of working-class individuals (33.5% vs. 14.5%), unemployment (18.1% vs. 7.3%), and young people not in school and unemployed (25.2% vs. 12.9%). They also show a lower median monthly income (€1,168 vs. €1,822), a higher poverty rate (43.3% vs. 15.5%), and a higher percentage of households living in overcrowded housing (22.0% vs. 8.7%). The chart highlights significant disparities in socio-economic conditions between disadvantaged areas and the rest of France, emphasizing the challenges faced by these communities.

FAQ

Le prix est calculé au même tarif que les tokens d’entrée, chaque image étant tokenisée.

Selon le modèle et la résolution, une image est tokenisée différemment. En voici un résumé.

Model

Résolution max.

≈ Formule

≈ N tokens max.

Mistral Large 31540x1540≈ (ResolutionX * ResolutionY) / 784≈ 3025
Mistral Small 3.21540x1540≈ (ResolutionX * ResolutionY) / 784≈ 3025
Mistral Medium 31540x1540≈ (ResolutionX * ResolutionY) / 784≈ 3025
Ministral 31540x1540≈ (ResolutionX * ResolutionY) / 784≈ 3025
Pixtral Large1024x1024≈ (ResolutionX * ResolutionY) / 256≈ 4096
Pixtral 12B1024x1024≈ (ResolutionX * ResolutionY) / 256≈ 4096

Si la résolution de l’image envoyée dépasse la résolution maximale du modèle, l’image est réduite à cette résolution maximale. Une erreur est renvoyée si la résolution dépasse 10000x10000.

Non, ils sont conçus pour comprendre et analyser des images, pas pour en générer.

Nous prenons actuellement en charge les formats d’image suivants :

  • PNG (.png)
  • JPEG (.jpeg et .jpg)
  • WEBP (.webp)
  • GIF non animé ne comportant qu’une seule image (.gif)

La taille maximale de fichier est actuellement de 10 Mo.

Le nombre maximal d’images par requête via l’API est de 8.

Pour en savoir plus sur les limites de débit, consultez Studio › LimitsarrowUpRight.