mistralM

Docs

sideBar

Clients SDK

Installez et utilisez les clients SDK officiels Python et TypeScript de l’API Mistral, ou trouvez des SDK tiers dans d’autres langages.

Les clients SDK vous permettent d’interagir avec l’API de Mistral AI dans le langage de programmation de votre choix ; ils implémentent des interfaces simples et claires vers nos endpoints et services d’API.<br /> Nous vous recommandons vivement d’utiliser les SDK officiels pour interagir avec nos API.

SDKs

Nous fournissons des clients SDK officiels en Python et en TypeScript ; vous trouverez aussi des SDK tiers non officiels dans d’autres langages.

Vous pouvez installer notre Python ClientarrowUpRight en exécutant :

pip install mistralai

Une fois l’installation terminée, vous pouvez par exemple exécuter une chat completion comme suit :

import os
from mistralai import Mistral

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

client = Mistral(api_key=api_key)

chat_response = client.chat.complete(
    model = model,
    messages = [
        {
            "role": "user",
            "content": "What is the best French cheese?",
        },
    ]
)
Sortie
{
  "id": "7c163b08d98e4eebb35564ae14ffe6e4",
  "created": 1756130273,
  "model": "mistral-medium-latest",
  "usage": {
    "prompt_tokens": 10,
    "total_tokens": 1160,
    "completion_tokens": 1150
  },
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "tool_calls": null,
        "content": "The \"best\" French cheese is highly subjective—it depends on personal taste, texture preferences, and how you plan to enjoy it (on a cheese board, melted, in cooking, etc.). However, here are some of the most **iconic, beloved, and award-winning French cheeses**, each celebrated for its unique qualities:\n\n### **Top Contenders for \"Best\" French Cheese**\n1. **Comté** (AOP)\n   - **Why?** A versatile, nutty, and complex **alpine cheese** aged 4 months to 3+ years. Younger Comté is mild and buttery; aged versions develop crystalline crunch and deep caramelized flavors.\n   - **Best for:** Cheese boards, fondue, grilled cheese, or eating plain.\n   - **Fun fact:** Made in the Jura Mountains, each wheel is unique based on the terroir and aging.\n\n2. **Roquefort** (AOP)\n   - **Why?** The **king of blue cheeses**, made from sheep’s milk and aged in natural caves. Creamy, tangy, and intensely flavorful with a sharp, salty bite.\n   - **Best for:** Spread on bread with honey or pears, in salads, or sauces.\n   - **Fun fact:** One of the oldest cheeses in France (mentioned by Pliny the Elder in 79 AD).\n\n3. **Camembert de Normandie** (AOP)\n   - **Why?** The **quintessential French cheese**—creamy, earthy, and slightly mushroomy when ripe. Invented in 1791 by Marie Harel.\n   - **Best for:** Baked (Camembert en croûte), with crusty bread, or apples.\n   - **Pro tip:** Eat it at room temperature when the center is soft but not runny.\n\n4. **Époisses de Bourgogne** (AOP)\n   - **Why?** A **pungent, washed-rind cheese** with a velvety texture and bold, barnyardy flavor. Napoleon reportedly loved it.\n   - **Best for:** Spreading on bread or pairing with Burgundy wine.\n   - **Warning:** So strong it’s banned on French public transport!\n\n5. **Reblochon** (AOP)\n   - **Why?** The **star of tartiflette**—creamy, nutty, and slightly smoky. Made in the Alps with raw cow’s milk.\n   - **Best for:** Melting in tartiflette, raclette, or on potatoes.\n\n6. **Brie de Meaux** (AOP)\n   - **Why?** The **\"King of Cheeses\"** (as declared at the 1815 Congress of Vienna). Rich, buttery, and mushroomy with a soft rind.\n   - **Best for:** Pairing with Champagne or fruit (grapes, figs).\n\n7. **Munster (Munster-Géromé)** (AOP)\n   - **Why?** A **stinky, washed-rind cheese** from Alsace with a creamy, tangy interior. Often served with cumin.\n   - **Best for:** Melting in tarts or eating with beer.\n\n8. **Beaufort** (AOP)\n   - **Why?** A **firm, nutty alpine cheese** similar to Gruyère but richer. Aged versions are caramelized and complex.\n   - **Best for:** Fondue, gratins, or shaving over salads.\n\n9. **Pélardon** (AOP)\n   - **Why?** A **small, tangy goat cheese** from the Cévennes or Provence. Comes in fresh (soft) or aged (firm, peppery) varieties.\n   - **Best for:** Salads, tartines, or grilled with herbs.\n\n10. **Bleu d’Auvergne** (AOP)\n   - **Why?** A **creamy, spicy blue cheese** with a sharper taste than Roquefort but less crumbly.\n   - **Best for:** Dressings, burgers, or cheese plates with walnuts.\n\n### **How to Choose?**\n- **Mild & creamy?** → Brie de Meaux, Camembert, Saint-André.\n- **Bold & stinky?** → Époisses, Munster, Pont-l’Évêque.\n- **Nutty & firm?** → Comté, Beaufort, Cantal.\n- **Blue cheese lover?** → Roquefort, Bleu d’Auvergne.\n- **Goat cheese fan?** → Crottin de Chavignol, Pélardon, Valençay.\n\n### **Pro Tips for Enjoying French Cheese**\n- **Serve at room temperature** (take it out of the fridge 1–2 hours before eating).\n- **Pair with wine**: Brie + Champagne, Roquefort + Sauternes, Comté + Jura wine.\n- **Avoid plastic wrap**—store in cheese paper or a breathable container.\n- **Visit a *fromagerie*** in France for expert recommendations!\n\n### **Final Verdict**\nIf forced to pick **one \"best\"**, **Comté** (aged 24+ months) and **Roquefort** are often crowned for their depth and versatility. But the true joy of French cheese is in the **diversity**—so try them all!\n\n**What’s your favorite?** 😊🧀"
      }
    }
  ]
}

Consultez d’autres exemples herearrowUpRight.