using NUnit.Framework; using OpenAI.Chat; using System; using System.ClientModel; namespace OpenAI.Examples; public partial class ChatExamples { [Test] public void Example02_SimpleChatStreaming() { ChatClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); CollectionResult completionUpdates = client.CompleteChatStreaming("Say 'this is a test.'"); Console.Write($"[ASSISTANT]: "); foreach (StreamingChatCompletionUpdate completionUpdate in completionUpdates) { if (completionUpdate.ContentUpdate.Count > 0) { Console.Write(completionUpdate.ContentUpdate[0].Text); } } } }