Reach out

Command Palette

Search for a command to run...

[Deployment]

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Introduction

Mistral AI models are available on the Outscale platform as managed deployments. Through the Outscale marketplace, you can subscribe to a Mistral service that will, on your behalf, provision a virtual machine and a GPU then deploy the model on it.

As of today, the following models are available:

  • Mistral Small (24.09)
  • Codestral (24.05)
  • Ministral 8B (24.10)

For more details, visit the models page.

Getting started

The following sections outline the steps to query a Mistral model on the Outscale platform.

Deploying the model

Follow the steps described in the Outscale documentation to deploy a service with the model of your choice.

Querying the model (chat completion)

Deployed models expose a REST API that you can query using Mistral's SDK or plain HTTP calls. To run the examples below you will need to set the following environment variables:

  • OUTSCALE_SERVER_URL: the URL of the VM hosting your Mistral model
  • OUTSCALE_MODEL_NAME: the name of the model to query (e.g. small-2409, codestral-2405)
1    client = Mistral(server_url=os.environ["OUTSCALE_SERVER_URL"])
2
3    resp = client.chat.complete(
4        model=os.environ["OUTSCALE_MODEL_NAME"],
5        messages=[
6            {
7                "role": "user",
8                "content": "Who is the best French painter? Answer in one short sentence.",
9            }
10        ],
11        temperature=0
12    )
13
14    print(resp.choices[0].message.content)
15    ```
16</TabItem>
17<TabItem value="ts" label="TypeScript">
18    ```typescript
19    import { Mistral } from "@mistralai/mistralai";
20
21    const client = new Mistral({
22        serverURL: process.env.OUTSCALE_SERVER_URL || ""
23    });
24
25    const modelName = process.env.OUTSCALE_MODEL_NAME|| "";
26
27    async function chatCompletion(user_msg: string) {
28        const resp = await client.chat.complete({
29            model: modelName,
30            messages: [
31                {
32                    content: user_msg,
33                    role: "user",
34                },
35            ],
36        });
37        if (resp.choices && resp.choices.length > 0) {
38            console.log(resp.choices[0]);
39        }
40    }
41
42    chatCompletion("Who is the best French painter? Answer in one short sentence.");
43    ```
44</TabItem>

Querying the model (FIM completion)

Codestral can be queried using an additional completion mode called fill-in-the-middle (FIM). For more information, see the code generation section.

1    client = Mistral(server_url=os.environ["OUTSCALE_SERVER_URL"])
2
3    resp = client.fim.complete(
4        model = os.environ["OUTSCALE_MODEL_NAME"],
5        prompt="def count_words_in_file(file_path: str) -> int:",
6        suffix="return n_words"
7    )
8
9    print(resp.choices[0].message.content)
10   ```
11</TabItem>
12<TabItem value="ts" label="TypeScript">
13   ```typescript
14    import { Mistral} from "@mistralai/mistralai";
15
16    const client = new Mistral({
17        serverURL: process.env.OUTSCALE_SERVER_URL || ""
18    });
19
20    const modelName = "codestral-2405";
21
22    async function fimCompletion(prompt: string, suffix: string) {
23        const resp = await client.fim.complete({
24            model: modelName,
25            prompt: prompt,
26            suffix: suffix
27        });
28        if (resp.choices && resp.choices.length > 0) {
29            console.log(resp.choices[0]);
30        }
31    }
32
33    fimCompletion("def count_words_in_file(file_path: str) -> int:",
34                  "return n_words");
35   ```
36</TabItem>

Going further

For more information and examples, you can check: