Skip to content

MEAI Tools

Example showing how to create MEAI AIFunction tools from the Topaz client.

This example assumes using Topaz; is in scope and apiKey contains your Topaz API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Create AIFunction tools from the Topaz client for use with any `IChatClient`.

var apiKey =
    Environment.GetEnvironmentVariable("TOPAZ_API_KEY") is { Length: > 0 } apiKeyValue
        ? apiKeyValue
        : throw new AssertInconclusiveException("TOPAZ_API_KEY environment variable is not found.");

using var client = new TopazClient(apiKey);

// Create tools that wrap the core async-job workflow:
var enhanceImageTool = client.AsEnhanceImageTool();
var getImageStatusTool = client.AsGetImageStatusTool();
var downloadImageResultTool = client.AsDownloadImageResultTool();
var getVideoStatusTool = client.AsGetVideoStatusTool();

// Wire them up to an IChatClient:
// ```csharp
// var options = new ChatOptions
// {
//     Tools = [enhanceImageTool, getImageStatusTool, downloadImageResultTool, getVideoStatusTool],
// };
// ```