Mistral AI Translation
Use Mistral AI as a translation provider into directive @strTranslate
, to translate a field value to your desired language.
Description
Make Mistral AI's API available as a translation provider in directive @strTranslate
.
Add directive @strTranslate
to any field of type String
, to translate it to the desired language.
For instance, this query translates the post's title
and content
fields from English to French using the Mistral AI API:
{
posts {
title @strTranslate(
from: "en",
to: "fr",
provider: mistral
)
content @strTranslate(
from: "en",
to: "fr",
provider: mistral
)
}
}
Mistral AI Authorization
In order to use Mistral AI, it is mandatory to provide your Mistral AI API key, via tab "Plugin Management => Mistral AI Translation" on the Settings page.
Create the API key in your Mistral AI's account.
Then follow one of the methods below to input the value.
By Settings
Input the API key in the corresponding inputs in the Settings page, and click on "Save Changes (All)":

wp-config.php
In
Add constant GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_MISTRALAI_API_KEY
in wp-config.php
:
define( 'GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_MISTRALAI_API_KEY', '{your API key}' );
By environment variable
Define environment variable MISTRALAI_TRANSLATION_SERVICES_MISTRALAI_API_KEY
.
Mistral AI model
You can customize which Mistral AI model to use to execute the translation.
The following models are supported:
- Codestral (
codestral-latest
) - Mistral Large (
mistral-large-latest
) - Pixtral Large (
pixtral-large-latest
) - Mistral Saba (
mistral-saba-latest
) - Ministral 3B (
ministral-3b-latest
) - Ministral 8B (
ministral-8b-latest
) - Mistral Small (
mistral-small-latest
) - Pixtral (
pixtral-12b-2409
) - Mistral Nemo (
open-mistral-nemo
) - Codestral Mamba (
open-codestral-mamba
)
Follow one of the methods below to input the value.
By Settings
Input the model in the corresponding input in the Settings page, and click on "Save Changes (All)":

wp-config.php
In
Add constant GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_MODEL
in wp-config.php
:
define( 'GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_MODEL', 'codestral-latest' );
By environment variable
Define environment variable MISTRALAI_TRANSLATION_SERVICES_MODEL
.
Translation prompt
You can customize the prompt to pass Mistral AI to execute the translation.
Follow one of the methods below to input the value.
By Settings
Input the "System message" and "Prompt template" in the corresponding inputs in the Settings page, and click on "Save Changes (All)":

wp-config.php
In
Add constants GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_SYSTEM_MESSAGE
and GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_PROMPT_TEMPLATE
in wp-config.php
:
define( 'GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_SYSTEM_MESSAGE', 'You are a helpful translator' );
define( 'GATOGRAPHQL_MISTRALAI_TRANSLATION_SERVICES_PROMPT_TEMPLATE', 'Please translate strings from {$sourceLang} to {$targetLang}' );
By environment variable
Define environment variables MISTRALAI_TRANSLATION_SERVICES_SYSTEM_MESSAGE
and MISTRALAI_TRANSLATION_SERVICES_PROMPT_TEMPLATE
.