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

# Mistral AI

> Mistral AI is a cutting-edge platform focused on developing advanced large language models that prioritize efficiency and performance. Known for producing compact yet powerful AI models, Mistral AI aims to democratize access to high-performance AI by making these models more accessible and adaptable to various applications. The platform emphasizes open innovation, contributing to the AI community with tools that are both versatile and state-of-the-art.

## Setup

1. Install Langtrace's SDK and [initialize](/quickstart) the SDK in your code.

*Note: You'll need API keys from Langtrace and MistralAI. Sign up for [Langtrace](https://langtrace.ai) and/or [MistralAI](https://mistral.ai/) if you haven't done so already.*

```bash Python theme={null}
# Install the SDK
pip install -U langtrace-python-sdk mistralai
```

2. Setup environment variables:

```bash Shell theme={null}
export LANGTRACE_API_KEY=YOUR_LANGTRACE_API_KEY
export MISTRAL_API_KEY=YOUR_MISTRAL_API_KEY
```

## Usage

Generate a simple output with your deployment's model:

<CodeGroup>
  ```python Python theme={null}
  import os
  from langtrace_python_sdk import langtrace, with_langtrace_root_span
  from mistralai import Mistral

  langtrace.init(api_key=os.environ["LANGTRACE_API_KEY"])


  @with_langtrace_root_span("chat_complete")
  def chat_complete():
      model = "mistral-large-latest"
      client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
      chat_response = client.chat.complete(
          model=model,
          messages=[
              {
                  "role": "user",
                  "content": "I need 10 cocktail recipes with tequila other than the classics like margarita, tequila"
              },
          ]
      )
      print(chat_response.choices[0].message.content)


  chat_complete()

  ```
</CodeGroup>

You can now view and analyze your traces on the Langtrace dashboard. Here's what you can expect:

1. View all your Mistral AI traces in the main traces view:
   <img src="https://mintcdn.com/langtraceai-2/m7BVnnhK3Cx2yRxS/images/mistral/mistral-langtrace-1.png?fit=max&auto=format&n=m7BVnnhK3Cx2yRxS&q=85&s=94ee9223adac1729ef932bc36a44ff38" alt="Mistral AI Traces Overview" width="3064" height="1436" data-path="images/mistral/mistral-langtrace-1.png" />

2. Dive deep into conversation details and responses:
   <img src="https://mintcdn.com/langtraceai-2/m7BVnnhK3Cx2yRxS/images/mistral/mistral-langtrace-2.png?fit=max&auto=format&n=m7BVnnhK3Cx2yRxS&q=85&s=1c825fc54d272d18893053aa5e1c9507" alt="Mistral AI Conversation Details" width="2948" height="1434" data-path="images/mistral/mistral-langtrace-2.png" />

3. Analyze span timing and relationships in the trace visualization:
   <img src="https://mintcdn.com/langtraceai-2/m7BVnnhK3Cx2yRxS/images/mistral/mistral-langtrace-3.png?fit=max&auto=format&n=m7BVnnhK3Cx2yRxS&q=85&s=bbfba9a0bfce0cce133b1bce2c4d4c2c" alt="Mistral AI Span Graph" width="2926" height="1436" data-path="images/mistral/mistral-langtrace-3.png" />

Want to see more supported methods? Check out the sample code in the [Langtrace Mistral Python Example](https://github.com/Scale3-Labs/langtrace-python-sdk/tree/main/src/examples/mistral_example) repository.

For advanced usage patterns and detailed examples, explore the [Langtrace Mistral Cookbook](https://github.com/mistralai/cookbook/blob/main/third_party/Langtrace/langtrace_mistral.ipynb) in the official Mistral AI cookbook repository.
