openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
main

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/overview/responses/developer_quickstart.cs

18lines · modepreview

// SAMPLE: Generate text from a simple prompt through Responses API
// PAGE: https://platform.openai.com/docs/overview
// GUIDANCE: Instructions to run this code: https://aka.ms/oai/net/start
#pragma warning disable OPENAI001

#:package OpenAI@2.*

using OpenAI.Responses;

string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);

ResponseResult response = client.CreateResponse(
    "gpt-5.2",
    "Write a short bedtime story about a unicorn."
);

Console.WriteLine(response.GetOutputText());