Skip to main content

Crate azure_ai_foundry_tools

Crate azure_ai_foundry_tools 

Source
Expand description

§azure_ai_foundry_tools

Crates.io docs.rs License: MIT

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 tracing spans

§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)

ConstantModel IDPurpose
PREBUILT_READprebuilt-readGeneral OCR
PREBUILT_LAYOUTprebuilt-layoutLayout with tables
PREBUILT_INVOICEprebuilt-invoiceInvoice extraction
PREBUILT_RECEIPTprebuilt-receiptReceipt extraction
PREBUILT_ID_DOCUMENTprebuilt-idDocumentPassport / ID
PREBUILT_BUSINESS_CARDprebuilt-businessCardBusiness card

§Tracing Spans

SpanFields
foundry::vision::analyzefeatures
foundry::document_intelligence::analyzemodel_id
foundry::document_intelligence::get_resultoperation_location
foundry::document_intelligence::poll_until_completeoperation_location

§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.