Skip to content

Microsoft.Extensions.AI Integration

Cross-SDK comparison

See the centralized MEAI documentation for feature matrices and comparisons across all tryAGI SDKs.

The LalalAI SDK provides AIFunction tool wrappers compatible with Microsoft.Extensions.AI. These tools can be used with any IChatClient to give AI models access to LALAL.AI's audio stem separation task management, processing minutes tracking, and voice pack listing.

Installation

1
dotnet add package tryAGI.LalalAI

Available Tools

Method Tool Name Description
AsCheckTaskStatusTool() LalalAI_CheckTaskStatus Check status of audio processing tasks
AsGetMinutesLeftTool() LalalAI_GetMinutesLeft Get remaining processing minutes
AsListVoicePacksTool() LalalAI_ListVoicePacks List available voice packs
AsCancelTasksTool() LalalAI_CancelTasks Cancel in-progress tasks

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Microsoft.Extensions.AI;
using LalalAI;

var client = new LalalAIClient(
    apiKey: Environment.GetEnvironmentVariable("LALALAI_API_KEY")!);

var options = new ChatOptions
{
    Tools = [client.AsCheckTaskStatusTool()],
};

IChatClient chatClient = /* your chat client */;

var messages = new List<ChatMessage>
{
    new(ChatRole.User, "Check the status of my audio processing task abc123"),
};

while (true)
{
    var response = await chatClient.GetResponseAsync(messages, options);
    messages.AddRange(response.ToChatMessages());

    if (response.FinishReason == ChatFinishReason.ToolCalls)
    {
        var results = await response.CallToolsAsync(options);
        messages.AddRange(results);
        continue;
    }

    Console.WriteLine(response.Text);
    break;
}