This client is inspired from cohere-python
You can use the Mistral Python client to interact with the Mistral AI API.
Installing
From Source
This client uses poetry as a dependency and virtual environment manager.
You can install poetry with
poetry will set up a virtual environment and install dependencies with the following command:
Run examples
You can run the examples in the examples/ directory using poetry run or by entering the virtual environment using poetry shell.
API Key Setup
Running the examples requires a Mistral AI API key.
- Get your own Mistral API Key: https://docs.mistral.ai/#api-access
- Set your Mistral API Key as an environment variable. You only need to do this once.
# set Mistral API Key (using zsh for example) $ echo 'export MISTRAL_API_KEY=[your_key_here]' >> ~/.zshenv # reload the environment (or just quit and open a new terminal) $ source ~/.zshenv
Using poetry run
cd examples
poetry run python chat_no_streaming.pyUsing poetry shell
poetry shell cd examples >> python chat_no_streaming.py