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 Baseten SDK provides AIFunction tool wrappers compatible with Microsoft.Extensions.AI. These tools can be used with any IChatClient to give AI models access to Baseten's model deployment management, deployment status monitoring, and workspace secret listing.

Installation

1
dotnet add package Baseten

Available Tools

Method Tool Name Description
AsListModelsTool() BasetenListModels List all deployed ML models with names, IDs, and instance types
AsGetModelTool() BasetenGetModel Get details of a specific model by ID
AsGetDeploymentStatusTool() BasetenGetDeploymentStatus Get production deployment status, replica count, and autoscaling settings
AsListSecretsTool() BasetenListSecrets List workspace secrets (names only, values never returned)

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
34
35
36
37
38
39
using Baseten;
using Microsoft.Extensions.AI;

var basetenClient = new BasetenClient(
    apiKey: Environment.GetEnvironmentVariable("BASETEN_API_KEY")!);

var options = new ChatOptions
{
    Tools =
    [
        basetenClient.AsListModelsTool(),
        basetenClient.AsGetModelTool(),
        basetenClient.AsGetDeploymentStatusTool(),
        basetenClient.AsListSecretsTool(),
    ],
};

IChatClient chatClient = /* your chat client */;

var messages = new List<ChatMessage>
{
    new(ChatRole.User, "List all deployed models and check the production deployment status for each."),
};

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;
}