Friendly, minimal project demonstrating four ways to call a MistralAI LLM and integrate with LangWatch for tracing and metrics.
Tools used: MistralAI (model provider), LangWatch (tracing, monitoring and eval framework), LangChain (LLM orchestration), LiteLLM (wrapper works across all model providers), and ChainLit (easy to use chat frontend).
Project integrations shown in this repository are implemented using the tools listed above.
This repository is intentionally small and educational — it's a learning aid showing example wrappers for MistralAI integration with LangWatch in different scenarios:
- Direct Mistral client usage (mistral.py)
- LiteLLM provider usage (litellm_mistralai.py)
- LangChain integration (langchain_mistralai.py)
- LangChain + LiteLLM integration (langchain_litellm_mistralai.py)
📚 What you'll find
-
chat.py— a minimal Chainlit front-end showing how to stream tokens from a chosen backend. -
mistral.py— example of using the officialmistralaiclient. -
litellm_mistralai.py— example usinglitellm(provider agnostic wrapper). -
langchain_mistralai.py— example using LangChain's Mistral adapter. -
langchain_litellm_mistralai.py— LangChain with LiteLLM provider. -
requirements.txt— packages needed to run the examples. -
examples/run_example.py— a small runnable example script (see below). -
.env.example— sample environment file showing required keys.
Getting started — quick steps
- Install Python dependencies
python -m pip install -r requirements.txt- Create a
.envfile at the project root (you can copy.env.example) and fill in your API keys
# .env
MISTRAL_API_KEY=sk-your-mistral-key #https://admin.mistral.ai/organization/api-keys
LANGWATCH_API_KEY=sk-your-langwatch-key # optional (used for tracing/monitoring) https://app.langwatch.ai/
MODEL_NAME=ministral-3b-latest
LLM_PROVIDER=mistral- Run a simple example (choose a backend):
Launch Web Chat App: python -m chainlit run chat.py
CLI:
python run_example.py --backend mistral "What is the best French cheese and why?"
python run_example.py --backend litellm "Explain recursion in 30 words"
python run_example.py --backend langchain "Give me a short bio for Ada Lovelace"
python run_example.py --backend langchain_litellm "List 3 tips for unit testing"
This project is provided as-is for educational purposes. Feel free to reuse and adapt the code for experiments.