openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
docs/overview/responses/developer_quickstart.cs
15lines · modecode
| 1 | // SAMPLE: Generate text from a simple prompt through Responses API |
| 2 | // PAGE: https://platform.openai.com/docs/overview |
| 3 | // GUIDANCE: Instructions to run this code: https://aka.ms/oai/net/start |
| 4 | #pragma warning disable OPENAI001 |
| 5 | |
| 6 | #:package OpenAI@2.* |
| 7 | #:property PublishAot=false |
| 8 | |
| 9 | using OpenAI.Responses; |
| 10 | |
| 11 | string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!; |
| 12 | OpenAIResponseClient client = new(model: "gpt-5", apiKey: key); |
| 13 | OpenAIResponse response = client.CreateResponse("Write a short bedtime story about a unicorn."); |
| 14 | |
| 15 | Console.WriteLine(response.GetOutputText()); |