Mistral
Introduction
The Mistral connector lets you integrate generative AI capabilities into Mendix apps. Because the Mistral API is compatible with the OpenAI API, this module focuses on Mistral-specific UI while reusing operations from the OpenAI connector.
Features
The Mistral connector is commonly used for text generation based on the Chat Completions API and embeddings generation with the Embeddings API.
For more information about the available models, see Mistral models.
Image Generation
Mistral does not offer image generation models out of the box. You can equip a Mistral agent with an image generation tool (see Image generation), but the Mistral connector does not support this functionality.
Knowledge Base
The Mistral connector supports knowledge bases from providers such as pgVector, Mendix Cloud, Amazon Bedrock, and Azure AI Search.
Prerequisites
To use this connector, you need to sign up for a Mistral account and create an API key. For more information, see the Quickstart guide.
Dependencies
- Mendix Studio Pro 10.24.0 and above
- GenAI Commons module
- Encryption module
- Community Commons module
- OpenAI connector
Installation
Install all required modules from Mendix Marketplace as listed in the Dependencies section above.
To import the Mistral connector and the other modules into your app, follow the instructions in Using Marketplace Content.
Configuration
After you install the Mistral and OpenAI connectors, you can find them in the Marketplace Modules section of the App Explorer. The Mistral connector provides a domain model and several pages. You can reuse all activities to connect your app to Mistral from the OpenAI connector. To implement an activity, use it in a microflow. Configure the Encryption module to secure the connection between your app and Mistral.
General Configuration
- Add the module roles
OpenAIConnector.AdministratorandMistralConnector.Administratorto your Administrator user role in the Security settings of your app. - Add the MistralConfiguration_Overview page from the Mistral connector module (USE_ME > MistralConfiguration) to your navigation, or add
Snippet_MistralConfigurationsto a page that is already part of your navigation. - Continue setting up your Mistral configuration at runtime. For more information, see the Mistral Configuration section below.
- Configure the models for your use case.
Mistral Configuration
The following inputs are required for the Mistral configuration:
| Parameter | Value |
|---|---|
| Display name | The name identifier of a configuration (for example, MyConfiguration). |
| Endpoint | The API endpoint (for example, https://api.mistral.ai/v1/). |
| Token | The access token to authorize your API call. To get an API key, see the Quickstart. |
Configuring the Mistral Deployed Models
A deployed model represents a GenAI model instance that the app can use to generate text, embeddings, or images. For each model you want to invoke from your app, create a MistralDeployedModel record—a specialization of DeployedModel (and also a specialization of OpenAIDeployedModel). In addition to the model display name and a technical name or identifier, a Mistral deployed model contains a reference to the connection details configured in the previous step.
-
Click the three dots ( ) icon for a Mistral configuration and open Manage Deployed Models. You can use a predefined syncing method that retrieves all available models for the specified API key and filters them according to their capabilities. To use additional models made available by Mistral, add them manually by clicking New.
-
For each additional model, add a record. The following fields are required:
Field Description Display name The reference for app users when selecting the model. Model name The technical reference of the model. For Mistral, this equals the model ID (for example, mistral-medium-2508).Output modality The output of the model. This connector currently supports text, embedding, and image. Input modality The input modalities accepted by the model. This connector currently supports text and image. -
Close the Manage Deployed Models dialog box and test the configuration with the newly created deployed models.
Using GenAI Commons Operations
After completing the general setup above, you can use the microflow actions under the GenAI (Generate) category in the toolbox. These operations are part of GenAI Commons. Because OpenAI (and therefore Mistral) is compatible with the principles of GenAI Commons, you can pass a MistralDeployedModel to all GenAI Commons operations that expect the generalization of DeployedModel. All actions under GenAI (Generate) execute the appropriate provider-specific logic based on the specialization type passed (in this case, Mistral). From an implementation perspective, understanding the inner workings of this operation is not required. The GenAI Commons documentation describes the input, output, and behavior. The sections below list applicable operations and Mistral-specific aspects.
For more inspiration or guidance on how to use the microflow actions in your logic, download the GenAI Showcase App, which demonstrates a variety of examples covering all the operations mentioned.
Use the GenAI Commons toolbox actions to create the required request and handle the response for your use case.
The internal chat completion logic supports JSON mode, function calling, and vision for Mistral. Check the compatibility of available models with these functionalities, as this changes over time. The following sections list toolbox actions specifically for OpenAI-compatible APIs (especially Mistral).
Chat Completions
Operations for chat completions focus on generating text based on input. In this context, system prompts and user prompts are two key components that guide the language model in generating relevant and contextually appropriate responses. For more information on prompt types and message roles, see the ENUM_MessageRole enumeration. To learn more about how to create the right prompts for your use case, see the Read More section below.
The MistralDeployedModel is compatible with the two chat completions operations from GenAI Commons. While developing your custom microflow, drag and drop the following operations from the toolbox in Studio Pro under the GenAI (Generate) category:
- Chat Completions (with history)
- Chat Completions (without history)
JSON Mode
JSON mode instructs the model to return valid JSON. To use JSON mode with the Mistral connector, explicitly specify that a JSON structure is required in a conversation message (for example, in the system prompt). After creating the request but before passing it to the chat completions operation, use the Set Response Format toolbox action to set the response format to JSON.
Function Calling
Function calling enables LLMs to connect with external tools to gather information, run actions, convert natural language into structured data, and more. Function calling enables the model to intelligently decide when to let the Mendix app call one or more predefined function microflows to gather additional information for the assistant's response.
Mistral does not call the function. The model returns a tool called JSON structure that is used to build the input of the function (or functions) so they can run as part of the chat completions operation. Functions in Mendix are essentially microflows that can be registered within the request to the LLM. The OpenAI connector handles the tool call response and runs the function microflows until the API returns the assistant's final response for Mistral.
The GenAI Commons chat completions operations mentioned earlier run this implementation. As a developer, you must make the system aware of your functions and their purposes by registering the functions to the request. To do so, use the GenAI Commons operation Tools: Add Function to Request once per function before passing the request to the chat completions operation.
Function microflows can have none, one, or multiple primitive input parameters such as Boolean, Datetime, Decimal, Enumeration, Integer, or String. Additionally, they may accept the Request or Tool objects as inputs. The function microflow must return a string value.
Function calling is a very powerful capability and should be used with caution. Note that function microflows run in the context of the current user without enforcing entity-access. You can use $currentUser in XPath queries to ensure you retrieve and return only information that the end-user is allowed to view; otherwise, confidential information may become visible to the end-user in the assistant's response.
Mendix recommends building user confirmation logic into function microflows that potentially impact the world on behalf of the end-user. Examples of such microflows include sending an email, posting online, or making a purchase.
For more information, see Function Calling.
Adding Knowledge Bases
Adding knowledge bases to a call enables LLMs to retrieve information when related topics are mentioned. Including knowledge bases in the request object along with a name and description enables the model to intelligently decide when to let the Mendix app call one or more predefined knowledge bases, allowing the assistant to include additional information in its response.
Mistral does not directly connect to knowledge resources. The model returns a tool call JSON structure that builds the input of the retrievals so they can run as part of the chat completions operation. The OpenAI connector handles the tool call response for Mistral and runs the function microflows until the API returns the assistant's final response.
The GenAI Commons chat completions operations mentioned earlier run this functionality. As a developer, make the system aware of your indexes and their purpose by registering them with the request. Use the GenAI Commons operation Tools: Add Knowledge Base, which must be called once per knowledge resource before passing the request to the chat completions operation.
Note that the retrieval process is independent of the model provider and can be used with any model that supports function calling, as it relies on the generalized GenAICommons.ConsumedKnowledgeBase input parameter.
Vision
Vision enables models like Mistral Medium 3.1 and Mistral Small 3.2 to interpret and analyze images, allowing them to answer questions and perform tasks related to visual content. This integration of computer vision and language processing enhances the model's comprehension and makes it valuable for tasks involving visual information. To use vision with the Mistral connector, send an optional FileCollection containing one or multiple images along with a single message.
For Chat Completions without History, FileCollection is an optional input parameter.
For Chat Completions with History, FileCollection can optionally be added to individual user messages using Chat: Add Message to Request.
Use the two microflow actions from the OpenAI-specific toolbox—Files: Initialize Collection with OpenAI File and Files: Add OpenAIFile to Collection—to construct the input with either FileDocuments (for vision, this must be of type Image) or URLs. The GenAI Commons module exposes similar file operations that can be used for vision requests with the OpenAI connector for Mistral. However, these generic operations do not support the optional OpenAI API-specific Detail attribute.
For more information on vision, see the Mistral documentation.
Document Chat
Document chat enables the model to interpret and analyze PDF documents, allowing it to answer questions and perform tasks based on the document content. The Mistral connector does not support document chat because it requires its own API. To learn about Mistral's optical character recognition (OCR) capabilities, see the Document AI documentation.
Image Generations
The Mistral connector does not support image generation. To learn more about image generation with Mistral, see Image Generation in the Mistral documentation.
Embeddings Generation
Mistral provides vector embedding generation capabilities that can be invoked using this connector module. The MistralDeployedModel entity is compatible with the knowledge base operations from GenAI Commons.
To implement embeddings generation into your Mendix application, use the embeddings generation microflow actions from GenAI Commons. When developing your microflow, drag and drop the action you need from the GenAI (Generate) category in the Toolbox in Studio Pro:
- Generate Embeddings (String)
- Generate Embeddings (Chunk Collection)
Depending on the operation you use in the microflow, provide an InputText string or a ChunkCollection. The current version of this operation only supports the float representation of the resulting vector.
The Generate Embeddings (String) microflow action supports scenarios where the vector embedding of a single string must be generated (for example, to use for a nearest neighbor search across an existing knowledge base). Pass this input string directly as the InputText parameter of this microflow. Additionally, EmbeddingsOptions is optional and can be instantiated using Embeddings: Create EmbeddingsOptions from GenAI Commons. Use the GenAI Commons toolbox action Embeddings: Get First Vector from Response to retrieve the generated embeddings vector. Both operations can be found under GenAI Knowledge Base (Content) in the Toolbox in Studio Pro.
The Generate Embeddings (Chunk Collection) microflow action supports the more complex scenario where a collection of string inputs is vectorized in a single API call, such as when converting a collection of texts (chunks) into embeddings to be inserted into a knowledge base. Instead of calling the API for each string, executing a single call for a list of strings can significantly reduce HTTP overhead. Use the exposed microflows from GenAI Commons Chunks: Initialize ChunkCollection to create the wrapper and Chunks: Add Chunk to ChunkCollection, or Chunks: Add KnowledgeBaseChunk to ChunkCollection to construct the input. After a successful API call, the resulting embedding vectors are stored in the EmbeddingVector attribute in the same Chunk object.
To generate embeddings, it does not matter whether the ChunkCollection contains Chunks or its specialization KnowledgeBaseChunks. However, if the goal is to store the generated embedding vectors in a knowledge base (such as using the PgVector Knowledge Base module), Mendix recommends adding KnowledgeBaseChunks to the ChunkCollection and using these as input for the embeddings operations so they can later be used directly to populate the knowledge base.
OpenAI-compatible APIs do not support knowledge base interaction (inserting or retrieving chunks). For more information on ways to work with knowledge bases for embedding generation, see PgVector Knowledge Base and Setting Up a Vector Database.
Exposed Microflow Actions for OpenAI-compatible APIs
The exposed microflow actions used to construct requests via drag-and-drop for OpenAI-compatible APIs are listed below. You can find these microflows in the Toolbox in Studio Pro. These actions are only required if you need to add Mistral-specific options to your requests. For generic functionality, use the GenAI Commons toolbox actions to create the required Request and handle the Response. These actions are available under the GenAI (Request Building) and GenAI (Response Handling) categories in the Toolbox.
Set Response Format
This microflow changes the ResponseFormat of the OpenAIRequest_Extension object, which is created for a Request if not already present. This describes the format that the chat completions model must output. By default, models compatible with the OpenAI API return Text. To enable JSON mode, set the input value as JSONObject.
Files: Initialize Collection with OpenAI Image
This operation is currently not relevant for the Mistral connector.
Files: Add OpenAI Image to Collection
This operation is currently not relevant for the Mistral connector.
Image Generation: Set ImageOptions Extension
This operation is currently not relevant for the Mistral connector.
Technical Reference
The module includes technical reference documentation for the available entities, enumerations, activities, and other items that you can use in your application. You can view the information about each object in context by using the Documentation pane in Studio Pro.
The Documentation pane displays the documentation for the currently selected element. To view it, perform the following steps:
-
In the View menu of Studio Pro, select Documentation.
-
Click the element you want to view documentation for.
Tool Choice
Mistral supports the following tool choice types from GenAI Commons for the Tools: Set Tool Choice action. For API mapping reference, see the table below:
| GenAI Commons (Mendix) | Mistral |
|---|---|
| auto | auto |
| any | any |
| none | none |
GenAI Showcase App
For more inspiration or guidance on how to use these microflows in your logic, download the GenAI Showcase App, which demonstrates a variety of example use cases.
Troubleshooting
Attribute or Reference Required Error Message After Upgrade
If you encounter an error stating that an attribute or reference is required after an upgrade, upgrade all modules by right-clicking the error. Then upgrade Data Widgets.
Conflicted Lib Error After Module Import
If you encounter an error caused by conflicting Java libraries, such as java.lang.NoSuchMethodError: 'com.fasterxml.jackson.annotation.OptBoolean com.fasterxml.jackson.annotation.JsonProperty.isRequired()', synchronize all dependencies (App > Synchronize dependencies) and restart your application.