Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mistral Docs #163

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ HF_TOKEN=
# Fireworks
FIREWORKS_API_KEY=

# Mistral
MISTRAL_API_KEY=

# Together AI
TOGETHER_API_KEY=

Expand Down
1 change: 1 addition & 0 deletions guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Here are the instructions for:
- [Cohere](cohere.md)
- [Google](google.md)
- [Hugging Face](huggingface.md)
- [Mistral](mistral.md)
- [OpenAI](openai.md)
- [SambaNova](sambanova.md)
- [xAI](xai.md)
Expand Down
49 changes: 49 additions & 0 deletions guides/mistral.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Mistral

To use Mistral with `aisuite`, you’ll need a [Mistral account](https://console.mistral.ai/).

After logging in, go to [Workspace billing](https://console.mistral.ai/billing) and choose a plan
- **Experiment** *(Free, 1 request per second); or*
- **Scale** *(Pay per use).*

Visit the [API Keys](https://console.mistral.ai/api-keys/) section in your account settings and generate a new key. Once you have your key, add it to your environment as follows:

```shell
export MISTRAL="your-mistralai-api-key"
```
## Create a Chat Completion

Install the `mistralai` Python client:

Example with pip:
```shell
pip install mistralai
```

Example with poetry:
```shell
poetry add mistralai
```

In your code:
```python
import aisuite as ai
client = ai.Client()

provider = "mistral"
model_id = "mistral-large-latest"

messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What’s the weather like in Montréal?"},
]

response = client.chat.completions.create(
model=f"{provider}:{model_id}",
messages=messages,
)

print(response.choices[0].message.content)
```

Happy coding! If you’d like to contribute, please read our [Contributing Guide](../CONTRIBUTING.md).