This is an unofficial Dart/Flutter client for the Mistral AI API.
dart pub add mistralai_client_dart
import 'package:mistralai_client_dart/mistralai_client_dart.dart';
final client = MistralAIClient(apiKey: 'your api key here');
final modelsResult = await client.listModels();
final models = modelsResult.data?.map((e) => e.id).toList();
print(models?.join(', '));
const request = ChatCompletionRequest(
model: 'mistral-small-latest',
messages: [
UserMessage(content: UserMessageContent.string('Hello chat!')),
],
);
final chatCompletion = await client.chatComplete(request: request);
final chatMessage = chatCompletion.choices?[0].message;
print(chatMessage?.content);
final stream = client.chatStream(request: request);
await for (final completionChunk in stream) {
final chatMessage = completionChunk.choices[0].delta.content;
if (chatMessage != null) {
print(chatMessage);
}
}
final embeddings = await client.createEmbeddings(
request: const EmbeddingRequest(
model: 'mistral-embed',
input: EmbeddingRequestInput.arrayString(['Hello chat!']),
),
);
for (final data in embeddings.data) {
print('Embeddings: ${data.embedding}');
}
Check examples:
Check examples:
Check examples:
Check examples:
Check examples:
Check examples:
You can check the official Mistral AI docs.
For contributing guide please see CONTRIBUTING.md.
For Flutter Flow integration please use the mistralai_client_dart_flutter_flow package.
It's a version of this package that is adapted to work with Flutter Flow.
Part of the code was generated thx to openapi_spec package.