Skip to main content

SDK Clients

We provide client codes in both Python and Typescript.

Python​

You can install our Python Client by running:

pip install mistralai

Once installed, you can run the chat completion:

import os
from mistralai import Mistral

api_key = os.environ["MISTRAL_API_KEY"]
model = "mistral-large-latest"

client = Mistral(api_key=api_key)

chat_response = client.chat.complete(
model = model,
messages = [
{
"role": "user",
"content": "What is the best French cheese?",
},
]
)

print(chat_response.choices[0].message.content)

See more examples here.

Typescript​

You can install our Typescript Client in your project using:

npm install @mistralai/mistralai

Once installed, you can run the chat completion:

import { Mistral } from '@mistralai/mistralai';

const apiKey = process.env.MISTRAL_API_KEY || 'your_api_key';

const client = new Mistral({apiKey: apiKey});

const chatResponse = await client.chat.complete({
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​

icebaker/nano-bots

Dart​

nomtek/mistralai_client_dart

Elixir​

axonzeta/mistral_elixir

Go​

Gage-Technologies

Java​

langchain4j Spring AI

JavaScript / TypeScript​

Vercel AI SDK

PHP​

HelgeSverre/mistral partITech/php-mistral

Ruby​

gbaptista/mistral-ai wilsonsilva/mistral

Rust​

ivangabriele/mistralai-client-rs