import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
We provide client codes in both Python and Typescript.
Python
You can install our Python Client by running:
1pip install mistralaiOnce installed, you can run the chat completion:
1import os
2from mistralai import Mistral
3
4api_key = os.environ["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)
20See more examples here.
Typescript
You can install our Typescript Client in your project using:
1npm install @mistralai/mistralaiOnce installed, you can run the chat completion:
1import { Mistral } from '@mistralai/mistralai';
2
3const apiKey = process.env.MISTRAL_API_KEY || 'your_api_key';
4
5const client = new Mistral({ apiKey: apiKey });
6
7const chatResponse = await client.chat.complete({
8 model: 'mistral-tiny',
9 messages: [{ role: 'user', content: 'What is the best French cheese?' }],
10});
11
12console.log('Chat:', chatResponse.choices[0].message.content);See more examples here.
Third-party clients
Here are some clients built by the community for various other languages:
This section lists third-party clients in other languages provided by the community. Please note that these clients are not actively maintained or supported by Mistral AI. We recommend reaching out to the respective maintainers for any assistance or inquiries.
CLI
Dart
Elixir
Go
Java
JavaScript / TypeScript
PHP
HelgeSverre/mistral partITech/php-mistral
Ruby
gbaptista/mistral-ai wilsonsilva/mistral