mistralai_client_dart

Last updated:

0 purchases

mistralai_client_dart Image
mistralai_client_dart Images
Add to Cart

Description:

mistralai client dart

Mistral AI client for Dart #


Description #
This is an unofficial Dart/Flutter client for the Mistral AI API.
Installation #
dart pub add mistralai_client_dart
copied to clipboard
Usage #
Create client #
import 'package:mistralai_client_dart/mistralai_client_dart.dart';

final client = MistralAIClient(apiKey: 'your api key here');
copied to clipboard
List models #
final modelsResult = await client.listModels();
final models = modelsResult.data.map((e) => e.id).toList();
print(models.join(', '));
copied to clipboard
Chat #
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);
copied to clipboard
Chat stream #
final stream = client.chatStream(request: request);
await for (final completionChunk in stream) {
final chatMessage = completionChunk.choices[0].delta.content;
if (chatMessage != null) {
print(chatMessage);
}
}
copied to clipboard
Embeddings #
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}');
}
copied to clipboard
Function calling #
Check examples:

Function calling example

Files #
Check examples:

Files example

Fine-tuning Jobs #
Check examples:

Fine-tuning jobs example

Fill in the middle completion #
Check examples:

FIM completion example
FIM completion stream example

Agents #
Check examples:

Agents example

Resources #
You can check the official Mistral AI docs.
Contributing #
For contributing guide please see CONTRIBUTING.md.
Flutter Flow (deprecated) #
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.
Aknowledgements #
Part of the code was generated thx to openapi_spec package.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.