openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/sub-pr-1135

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/quickstart/responses/developer_quickstart.cs

18lines · modecode

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