Clients
We provide client codes in both Python and Javascript.
Python
You can install our Python Client by running:
pip install mistralai
Once installed, you can run the chat completion:
from mistralai.client import MistralClient
from mistralai.models.chat_completion import ChatMessage
api_key = os.environ["MISTRAL_API_KEY"]
model = "mistral-large-latest"
client = MistralClient(api_key=api_key)
chat_response = client.chat(
model=model,
messages=[ChatMessage(role="user", content="What is the best French cheese?")]
)
print(chat_response.choices[0].message.content)
See more examples here.
Javascript
You can install our Javascript Client in your project using:
npm install @mistralai/mistralai
Once installed, you can run the chat completion:
import MistralClient from '@mistralai/mistralai';
const apiKey = process.env.MISTRAL_API_KEY || 'your_api_key';
const client = new MistralClient(apiKey);
const chatResponse = await client.chat({
model: 'mistral-tiny',
messages: [{role: 'user', content: 'What is the best French cheese?'}],
});
console.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
PHP
HelgeSverre/mistral partITech/php-mistral
Ruby
gbaptista/mistral-ai wilsonsilva/mistral