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

docs/overview/responses/developer_quickstart.cs

15lines · modecode

1// SAMPLE: Generate text from a simple prompt through Responses API
2// PAGE: https://platform.openai.com/docs/overview
3// GUIDANCE: Instructions to run this code: https://aka.ms/oai/net/start
4#pragma warning disable OPENAI001
5
6#:package OpenAI@2.*
7#:property PublishAot=false
8
9using OpenAI.Responses;
10
11string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
12OpenAIResponseClient client = new(model: "gpt-5", apiKey: key);
13OpenAIResponse response = client.CreateResponse("Write a short bedtime story about a unicorn.");
14
15Console.WriteLine(response.GetOutputText());