openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
jsquire-patch-1

Branches

Tags

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

Clone

HTTPS

Download ZIP

examples/Responses/Example01_HelloWorldAsync.cs

19lines · modeblame

aaa924ecJose Arriaga Maldonado1 years ago1using NUnit.Framework;
2using OpenAI.Responses;
3using System;
4using System.Threading.Tasks;
5
6namespace OpenAI.Examples;
7
8public partial class ResponseExamples
9{
10[Test]
11public async Task Example01_HelloWorldAsync()
12{
13OpenAIResponseClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
14
15OpenAIResponse response = await client.CreateResponseAsync("Say 'this is a test.'");
16
17Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}");
18}
19}