Relatude Help

34.1 Text: embeddings and completions

// a completion with the configured model, or with a model from CompletionModelsByKey
string summary = await db.Services.AI.GetCompletionAsync("Summarise in one sentence: " + article.Body);
string careful = await db.Services.AI.GetCompletionAsync(prompt, modelKey: "strong");

// one vector per paragraph, in order
List<float[]> vectors = await db.Services.AI.GetEmbeddingsAsync(["first paragraph", "second paragraph"]);

To use the hosted Relatude AI service, set AISettings for the database (§12.1 lists every key and provider):

"AISettings": {
  "TypeName": "RelatudeServices",
  "CompletionModel": "fast",
  "CompletionModelsByKey": { "strong": "balanced" }
}
  • Model names. The hosted service has its own model keys: embedding-small and embedding-large for EmbeddingModel, fast and balanced for CompletionModel. Leave them empty for the service's default. CompletionModelsByKey maps your own keys onto them.
  • Semantic search computes embeddings by itself, so most applications never call GetEmbeddingsAsync.
  • Embeddings are cached on the server by text and model (AISettings.CacheType), so each text is paid for once. Completions are not cached.