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