openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
kc240611

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs

28lines · modecode

1using NUnit.Framework;
2using OpenAI.Assistants;
3using System;
4using System.ClientModel;
5using System.Threading.Tasks;
6
7namespace OpenAI.Examples;
8
9public partial class AssistantExamples
10{
11 [Test]
12 public async Task Example03_ListAssistantsWithPaginationAsync()
13 {
14 // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning.
15#pragma warning disable OPENAI001
16 AssistantClient client = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
17
18 int count = 0;
19
20 AsyncPageableCollection<Assistant> assistants = client.GetAssistantsAsync();
21 await foreach (Assistant assistant in assistants)
22 {
23 Console.WriteLine($"[{count,3}] {assistant.Id} {assistant.CreatedAt:s} {assistant.Name}");
24
25 count++;
26 }
27 }
28}
29