Skip to content

List Models

This example assumes using Instill; is in scope and apiKey contains your Instill 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
using var client = new InstillClient(apiKey);

GetAuthenticatedUserResponse userResponse = await client.Namespace.MgmtPublicServiceGetAuthenticatedUserAsync();
var namespaceName = $"namespaces/{userResponse.User!.Id}";

ListModelsResponse response;
try
{
    response = await client.Model.ModelPublicServiceListModelsAsync(
        parent: namespaceName);
}
catch (ApiException<RpcStatus> ex) when (ex.Message.Contains("core-model-backend", StringComparison.Ordinal))
{
    throw new AssertInconclusiveException("Instill model backend is currently unavailable.", ex);
}

foreach (var model in response.Models ?? [])
{
    Console.WriteLine($"Model: {model.Name}");
    Console.WriteLine($"  ID: {model.Id}");
    Console.WriteLine($"  Description: {model.Description}");
    Console.WriteLine();
}