> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Mistral SDK

> Learn how to integrate Maxim observability with the Mistral SDK in just one line of code.

export const MaximPlayer = ({url}) => {
  return <iframe className="border-background-highlight-secondary h-full w-full rounded-md border-2 aspect-video" src={url} allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowFullScreen></iframe>;
};

<MaximPlayer url="https://www.youtube.com/embed/qF5YtHvHWx8?si=ZiudWo8tExdLwwwX" />

## Requirements

```
mistralai
maxim-py
```

## Env Variables

```
MAXIM_API_KEY=
MAXIM_LOG_REPO_ID=
MISTRAL_API_KEY=
```

## Initialize Logger

```python theme={null}
from maxim import Maxim

logger = Maxim().logger()
```

## Initialize MaximMistralClient

```python {5-7} theme={null}
from mistralai import Mistral
from maxim.logger.mistral import MaximMistralClient
import os

with MaximMistralClient(Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
), logger) as mistral:
    # Your Mistral calls go here
    pass
```

## Make LLM Calls Using MaximMistralClient

```python theme={null}
from mistralai import Mistral
from maxim.logger.mistral import MaximMistralClient
import os

with MaximMistralClient(Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
), logger) as mistral:

    res = mistral.chat.complete(
        model="mistral-small-latest", 
        messages=[
            {
                "content": "Who is the best French painter? Answer in one short sentence.",
                "role": "user",
            },
        ]
    )

    # Handle response
    print(res)
```

<img src="https://mintcdn.com/maximai/3RnX5HkRjKtE2PMo/images/mistral_traces.gif?s=bd742fde80efffd04f399e26a12f7b5a" alt="mistral_traces.gif" width="1280" height="720" data-path="images/mistral_traces.gif" />

## Async LLM calls

```python theme={null}
async with MaximMistralClient(Mistral(
    api_key=os.getenv('MISTRAL_API_KEY', ''),
), logger) as mistral:
    
    response = await mistral.chat.complete_async(
        model='mistral-small-latest',
        messages=[
            {
                'role': 'user',
                'content': 'Explain the difference between async and sync programming in Python in one sentence.'
            }
        ]
    )    
    print(response)
```

## Supported Mistral Models

The MaximMistralClient supports all Mistral models available through the Mistral API, including:

* `mistral-small-latest`
* `mistral-medium-latest`
* `open-mistral-7b`
* And other available Mistral models

## Resources

You can quickly try the Mistral One Line Integration here -

<CardGroup cols={2}>
  <Card title="Mistral Integration Notebook (Colab)" icon="google" href="https://colab.research.google.com/drive/1gqJkkLQQTtSdUla2oiIg-QyR6i5BpmvV?usp=sharing" />
</CardGroup>
