Skip to content

MEAI Tools

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

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

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

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

using var client = new PicsartClient(apiKey);

// Create individual tools for specific capabilities:
var removeBackgroundTool = client.AsRemoveBackgroundTool();
var upscaleTool = client.AsUpscaleTool();
var textToImageTool = client.AsTextToImageTool();
var listEffectsTool = client.AsListEffectsTool();
var getBalanceTool = client.AsGetBalanceTool();

// These tools can be added to ChatOptions.Tools for any IChatClient:
// ```csharp
// var options = new ChatOptions
// {
//     Tools = [removeBackgroundTool, upscaleTool, textToImageTool],
// };
// ```