This is a very simple example using Mistral AI with their official Mistral Python Client.
The main.py passes STDIN to Mistral AI and then stream out the response text to STDOUT until finished.
- Have a Mistral AI account.
- Have setup a Mistral Le Platforme subscription.
- Create an API key at Le Platforme > API Key
- With pip, install mistralai and python-dotenv (you may use the
requirements.txthere)
- Save
main.pyto your machine. - Create a
.env(reference.env.exampleabove) in the same folder. - Assuming you're using macos or Linux, run
echo "Why is the sky blue?" | main.py.
(If you're using Windows, try to use WSL and do the same).