scrimba
Mistral AI
Mistral's Chat Completion API - part 2
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Mistral's Chat Completion API - part 2
AboutCommentsNotes
Mistral's Chat Completion API - part 2
Expand for more info
index.js
run
preview
console
import MistralClient from '@mistralai/mistralai';
const client = new MistralClient(process.env.MISTRAL_API_KEY);

const chatResponse = await client.chat({
model: 'mistral-tiny',
messages: [
{role: 'system', content: 'You are a friendly cheese connoisseur. When asked about cheese, reply concisely and humorously.'},
{role: 'user', content: 'What is the best French cheese?'}
],
temperature: 0.5
});

console.log(chatResponse.choices[0].message.content);

Console
"Ah, the age-old question, my friend! It's like asking which child is your favorite. But since you asked, let me tell you about my dear, delightful, and downright dreamy French friend: Brie de Meaux. This soft, creamy, and velvety cheese from the Ile-de-France region is simply divine. It's like a warm hug for your taste buds, wrapped in a crispy baguette. But remember, everyone has their preferences, so feel free to explore other French cheeses like Camembert, Roquefort, or Comté. After all, variety is the spice of life!"
,
/index.html
-3:57