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

# Mistral

> Auto-instrument Mistral AI API calls

Automatically capture all Mistral AI chat completion calls, including tool/function calls and streaming responses.

## Setup

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import traceroot
    from traceroot import Integration

    traceroot.initialize(integrations=[Integration.MISTRAL])
    ```
  </Tab>
</Tabs>

## Usage

Once initialized, all Mistral calls are captured automatically:

```python theme={null}
import os
from mistralai import Mistral

import traceroot
from traceroot import Integration

traceroot.initialize(integrations=[Integration.MISTRAL])

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

# This call is automatically traced
response = client.chat.complete(
    model="mistral-large-latest",
    messages=[
        {"role": "user", "content": "What is the capital of France?"},
    ],
)

print(response.choices[0].message.content)
```

## What Gets Captured

| Attribute  | Description                                          |
| ---------- | ---------------------------------------------------- |
| Model      | `mistral-large-latest`, `mistral-small-latest`, etc. |
| Messages   | Input messages array                                 |
| Response   | Completion content                                   |
| Tool calls | Function calls emitted by the model                  |
| Tokens     | Input and output tokens                              |
| Cost       | Calculated from token usage and model pricing        |
| Latency    | Request duration                                     |

## Run the example

Clone the repo and run a complete agent end-to-end.

<Card title="Python" icon="python" href="https://github.com/traceroot-ai/traceroot/tree/main/examples/python/mistral-tool-agent">
  Run the Python example
</Card>
