openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
examples/Chat/Example01_SimpleChat.cs
18lines · modecode
| 1 | using NUnit.Framework; |
| 2 | using OpenAI.Chat; |
| 3 | using System; |
| 4 | |
| 5 | namespace OpenAI.Examples; |
| 6 | |
| 7 | public partial class ChatExamples |
| 8 | { |
| 9 | [Test] |
| 10 | public void Example01_SimpleChat() |
| 11 | { |
| 12 | ChatClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")); |
| 13 | |
| 14 | ChatCompletion completion = client.CompleteChat("Say 'this is a test.'"); |
| 15 | |
| 16 | Console.WriteLine($"[ASSISTANT]: {completion.Content[0].Text}"); |
| 17 | } |
| 18 | } |