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 91011121314151617181920212223
// Create AIFunction tools from the Picsart client for use with any `IChatClient`.varapiKey=Environment.GetEnvironmentVariable("PICSART_API_KEY")is{Length:>0}apiKeyValue?apiKeyValue:thrownewAssertInconclusiveException("PICSART_API_KEY environment variable is not found.");usingvarclient=newPicsartClient(apiKey);// Create individual tools for specific capabilities:varremoveBackgroundTool=client.AsRemoveBackgroundTool();varupscaleTool=client.AsUpscaleTool();vartextToImageTool=client.AsTextToImageTool();varlistEffectsTool=client.AsListEffectsTool();vargetBalanceTool=client.AsGetBalanceTool();// These tools can be added to ChatOptions.Tools for any IChatClient:// ```csharp// var options = new ChatOptions// {// Tools = [removeBackgroundTool, upscaleTool, textToImageTool],// };// ```