openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.9.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

examples/Responses/Example01_SimpleResponseAsync.cs

25lines · modecode

1using NUnit.Framework;
2using OpenAI.Responses;
3using System;
4using System.Threading.Tasks;
5
6namespace OpenAI.Examples;
7
8// This example uses experimental APIs which are subject to change. To use experimental APIs,
9// please acknowledge their experimental status by suppressing the corresponding warning.
10#pragma warning disable OPENAI001
11
12public partial class ResponseExamples
13{
14 [Test]
15 public async Task Example01_SimpleResponseAsync()
16 {
17 ResponsesClient client = new(apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
18
19 ResponseResult response = await client.CreateResponseAsync("gpt-5", "Say 'this is a test.'");
20
21 Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}");
22 }
23}
24
25#pragma warning restore OPENAI001