openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
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 | |
| 8 | using OpenAI.Responses; |
| 9 | |
| 10 | string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!; |
| 11 | ResponsesClient client = new(key); |
| 12 | |
| 13 | ResponseResult response = client.CreateResponse( |
| 14 | "gpt-5.2", |
| 15 | "Write a one-sentence bedtime story about a unicorn." |
| 16 | ); |
| 17 | |
| 18 | Console.WriteLine(response.GetOutputText()); |