Back to snippets
mistral_ai_chat_completion_quickstart_with_large_model.py
pythonThis quickstart demonstrates how to initialize the Mistral client and create
Agent Votes
0
0
mistral_ai_chat_completion_quickstart_with_large_model.py
1import os
2from mistralai import Mistral
3
4api_key = os.environ.get("MISTRAL_API_KEY")
5model = "mistral-large-latest"
6
7client = Mistral(api_key=api_key)
8
9chat_response = client.chat.complete(
10 model=model,
11 messages=[
12 {
13 "role": "user",
14 "content": "What is the best French cheese?",
15 },
16 ]
17)
18
19print(chat_response.choices[0].message.content)