openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/fix-codeinterpretertoolcontainer

Branches

Tags

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

Clone

HTTPS

Download ZIP

docs/guides/text/chat/chat_simpleprompt.cs

11lines · modecode

1// SAMPLE: Generate text from a simple prompt
2// GUIDANCE: Instructions to run this code: https://aka.ms/oai/net/start
3#:package OpenAI@2.*
4#:property PublishAot=false
5
6using OpenAI.Chat;
7
8string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
9ChatClient client = new("gpt-4.1", key);
10ChatCompletion acompletion = client.CompleteChat("Write a one-sentence bedtime story about a unicorn.");
11Console.WriteLine(acompletion.Content[0].Text);