The Roboflow SDK provides AIFunction tool wrappers compatible with Microsoft.Extensions.AI. These tools can be used with any IChatClient to give AI models access to Roboflow's computer vision inference including object detection, classification, and OCR.
Installation
1
dotnetaddpackageRoboflow
Object Detection Tool
Use AsObjectDetectionTool() to detect objects in images using a Roboflow model:
1 2 3 4 5 6 7 8 91011121314151617
usingRoboflow;usingMicrosoft.Extensions.AI;varroboflowClient=newRoboflowClient(apiKey:Environment.GetEnvironmentVariable("ROBOFLOW_API_KEY")!);vardetectionTool=roboflowClient.AsObjectDetectionTool(confidence:0.5);// Use with any IChatClientIChatClientchatClient=/* your chat client */;varoptions=newChatOptions{Tools=[detectionTool],};varresponse=awaitchatClient.GetResponseAsync("Detect all objects in this image: https://example.com/photo.jpg",options);
Use AsOcrTool() to extract text from images using the DocTR OCR model:
1 2 3 4 5 6 7 8 910
varocrTool=roboflowClient.AsOcrTool();varoptions=newChatOptions{Tools=[ocrTool],};varresponse=awaitchatClient.GetResponseAsync("Extract all text from this document image: https://example.com/document.jpg",options);
Instance Segmentation Tool
Use AsInstanceSegmentationTool() to run pixel-level instance segmentation: