openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.6.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

examples/Responses/Example01_SimpleResponse.cs

24lines · modecode

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