openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/customize-openairesponsescontext-attribute

Branches

Tags

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

Clone

HTTPS

Download ZIP

examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs

33lines · modecode

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