05-25-2026, 11:38 AM
Create this script. Run once. Later, if everything OK, add its name in Options > Workspace > Startup scripts.
Then in Options > AI you'll see Mistral in the Embedding and API keys combo boxes. Select them, enter your Mistral API key, OK.
Then try to search. The first time it will create AI embedding vectors using the Mistral API. If it is very slow and hangs, probably you use Mistral without subscription. It's free but limited. A workaround of using it without subscription exists.
// script "init AI.cs"
/*/ role editorExtension; testInternal Au.Editor; r Au.Editor.dll; /*/
using System.Text.Json.Nodes;
using AI;
AiModel.Models.Add(new ModelMistralEmbed());
record class ModelMistralEmbed : AiEmbeddingModel {
public ModelMistralEmbed() : base("Mistral", "https://api.mistral.ai/v1/embeddings", "codestral-embed", 1024, "float", new(32000, 256, requestPeriod: 1100)) { }
//"mistral-embed" (only 1024 dim float), "codestral-embed"
public override object GetPostData(IList<EmInput> input, bool isQuery)
=> new { model, input, output_dimension = dimensions, output_dtype = emType };
public override IEnumerable<JsonNode> GetVectors(JsonNode j)
=> j["data"].AsArray().Select(o => o["embedding"]);
public override int GetTokens(JsonNode j)
=> (int)j["usage"]["total_tokens"];
}Then in Options > AI you'll see Mistral in the Embedding and API keys combo boxes. Select them, enter your Mistral API key, OK.
Then try to search. The first time it will create AI embedding vectors using the Mistral API. If it is very slow and hangs, probably you use Mistral without subscription. It's free but limited. A workaround of using it without subscription exists.
