Expand description
§azure_ai_foundry_tools
Vision and Document Intelligence clients for the Azure AI Foundry Rust SDK.
§Features
- Vision — Image Analysis 4.0: tags, captions, object detection, OCR, smart crops, people
- Document Intelligence — Document Intelligence v4.0: OCR, layout, invoices, receipts, ID documents, business cards
- Tracing — Full instrumentation with
tracingspans
§Installation
[dependencies]
azure_ai_foundry_core = "0.8"
azure_ai_foundry_tools = "0.8"
tokio = { version = "1", features = ["full"] }§Usage
§Analyze an Image
use azure_ai_foundry_core::client::FoundryClient;
use azure_ai_foundry_core::auth::FoundryCredential;
use azure_ai_foundry_tools::vision::{self, ImageAnalysisRequest, VisualFeature};
let client = FoundryClient::builder()
.endpoint("https://your-resource.services.ai.azure.com")
.credential(FoundryCredential::api_key("your-key"))
.build()?;
let request = ImageAnalysisRequest::builder()
.url("https://example.com/image.jpg")
.features(vec![VisualFeature::Tags, VisualFeature::Caption])
.try_build()?;
let result = vision::analyze(&client, &request).await?;
if let Some(caption) = &result.caption_result {
println!("Caption: {} ({:.1}%)", caption.text, caption.confidence * 100.0);
}§Analyze a Document
use azure_ai_foundry_core::client::FoundryClient;
use azure_ai_foundry_core::auth::FoundryCredential;
use azure_ai_foundry_tools::document_intelligence::{
self, DocumentAnalysisRequest, PREBUILT_READ,
};
let client = FoundryClient::builder()
.endpoint("https://your-resource.services.ai.azure.com")
.credential(FoundryCredential::api_key("your-key"))
.build()?;
let request = DocumentAnalysisRequest::builder()
.model_id(PREBUILT_READ)
.url_source("https://example.com/document.pdf")
.try_build()?;
let operation = document_intelligence::analyze(&client, &request).await?;
let result = document_intelligence::poll_until_complete(
&client,
&operation.operation_location,
std::time::Duration::from_secs(2),
60,
).await?;
if let Some(ar) = &result.analyze_result {
println!("Extracted text: {:?}", ar.content);
}§Supported Models (Document Intelligence)
| Constant | Model ID | Purpose |
|---|---|---|
PREBUILT_READ | prebuilt-read | General OCR |
PREBUILT_LAYOUT | prebuilt-layout | Layout with tables |
PREBUILT_INVOICE | prebuilt-invoice | Invoice extraction |
PREBUILT_RECEIPT | prebuilt-receipt | Receipt extraction |
PREBUILT_ID_DOCUMENT | prebuilt-idDocument | Passport / ID |
PREBUILT_BUSINESS_CARD | prebuilt-businessCard | Business card |
§Tracing Spans
| Span | Fields |
|---|---|
foundry::vision::analyze | features |
foundry::document_intelligence::analyze | model_id |
foundry::document_intelligence::get_result | operation_location |
foundry::document_intelligence::poll_until_complete | operation_location |
§Related Crates
azure_ai_foundry_core— Core types, authentication, and HTTP clientazure_ai_foundry_models— Chat completions and embeddingsazure_ai_foundry_agents— Agent Service client
§License
This project is licensed under the MIT License.
Modules§
- document_
intelligence - Document Intelligence client for Azure AI Foundry Document Intelligence API v4.0.
- models
- Shared types for Azure AI Foundry Vision and Document Intelligence services.
- vision
- Image Analysis client for Azure AI Foundry Vision API 4.0.