> ## 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.

## Install

> [tab] Python
>
> ```bash theme={null}
> pip install traceroot mistralai
> ```

## Set up

> [tab] Python
>
> ```python theme={null}
> import traceroot
> from traceroot import Integration
>
> traceroot.initialize(integrations=[Integration.MISTRAL])
> ```

## Usage

Once initialized, all Mistral calls are captured automatically:

```python theme={null}
import os
from mistralai.client 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)
```

## Verify

Run your code and confirm the trace arrives:

1. **In the traceroot UI**: Navigate to **Tracing > Traces** in [traceroot Cloud](https://app.traceroot.ai). You should see a trace with root span `Chat.complete` (or `Chat.stream` when streaming).
2. **Via the CLI**: Run `traceroot traces list` to inspect your recent traces from the terminal.

## 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 | Not currently calculated for Mistral model IDs; token usage is still captured |
| Latency | Request duration |

## Limitations

None known.

## Run the example

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

> [card] [Python](https://github.com/traceroot-ai/traceroot/tree/main/examples/python/mistral-tool-agent)
>
> Run the Python example

## Next steps

> [card] [Python SDK Reference](https://traceroot.ai/docs/tracing/python-sdk.md)
>
> Explore the full Python SDK reference and instrumentation options.

> [card] [Cost Tracking](https://traceroot.ai/docs/tracing/cost-tracking.md)
>
> Learn how traceroot calculates token costs and tracks model spend.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.