openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.10.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

examples/Responses/Example01_SimpleResponseAsync.cs

25lines · modeblame

aaa924ecJose Arriaga Maldonado1 years ago1using NUnit.Framework;
2using OpenAI.Responses;
3using System;
4using System.Threading.Tasks;
5
6namespace OpenAI.Examples;
7
5dce104aJose Arriaga Maldonado1 years ago8// 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
aaa924ecJose Arriaga Maldonado1 years ago12public partial class ResponseExamples
13{
14[Test]
5dce104aJose Arriaga Maldonado1 years ago15public async Task Example01_SimpleResponseAsync()
aaa924ecJose Arriaga Maldonado1 years ago16{
5ff668b5Copilot5 months ago17ResponsesClient client = new(apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
aaa924ecJose Arriaga Maldonado1 years ago18
5ff668b5Copilot5 months ago19ResponseResult response = await client.CreateResponseAsync("gpt-5", "Say 'this is a test.'");
aaa924ecJose Arriaga Maldonado1 years ago20
21Console.WriteLine($"[ASSISTANT]: {response.GetOutputText()}");
22}
23}
5dce104aJose Arriaga Maldonado1 years ago24
25#pragma warning restore OPENAI001