openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/sub-pr-1011

Branches

Tags

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

Clone

HTTPS

Download ZIP

examples/Chat/Example01_SimpleChat.cs

18lines · modecode

1using NUnit.Framework;
2using OpenAI.Chat;
3using System;
4
5namespace OpenAI.Examples;
6
7public 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}