openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
docs/quickstart/responses/analyze_images_files_image_url.cs
20lines · modecode
| 1 | // SAMPLE: Analyzes image from an image URL through Responses API |
| 2 | // PAGE: https://platform.openai.com/docs/quickstart?input-type=image-url#analyze-images-and-files |
| 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("gpt-5.2", [ |
| 14 | ResponseItem.CreateUserMessageItem([ |
| 15 | ResponseContentPart.CreateInputTextPart("What is in this image?"), |
| 16 | ResponseContentPart.CreateInputImagePart(new Uri("https://openai-documentation.vercel.app/images/cat_and_otter.png")) |
| 17 | ]) |
| 18 | ]); |
| 19 | |
| 20 | Console.WriteLine(response.GetOutputText()); |