Skip to content
azure-ai-document-intelligence-ts logo

Azure AI Document Intelligence TS

azure-ai-document-intelligence-ts

Extract text, tables, and structured data from documents using prebuilt and custom models.

ranbot-ai/awesome-skills0installs6stars

SKILL.md

Full skill instructions

Azure Document Intelligence REST SDK for TypeScript

Extract text, tables, and structured data from documents using prebuilt and custom models.

Installation

npm install @azure-rest/​ai-document-intelligence @azure/​identity

Environment Variables

DOCUMENT_INTELLIGENCE_ENDPOINT=https://<resource>.cognitiveservices.azure.com
DOCUMENT_INTELLIGENCE_API_KEY=<api-key>

Authentication

Important: This is a REST client. DocumentIntelligence is a function, not a class.

DefaultAzureCredential

import DocumentIntelligence from "@azure-rest/​ai-document-intelligence";
import { DefaultAzureCredential } from "@azure/​identity";

const client = DocumentIntelligence(
  process.env.DOCUMENT_INTELLIGENCE_ENDPOINT!,
  new DefaultAzureCredential()
);

API Key

import DocumentIntelligence from "@azure-rest/​ai-document-intelligence";

const client = DocumentIntelligence(
  process.env.DOCUMENT_INTELLIGENCE_ENDPOINT!,
  { key: process.env.DOCUMENT_INTELLIGENCE_API_KEY! }
);

Analyze Document (URL)

import DocumentIntelligence, {
  isUnexpected,
  getLongRunningPoller,
  AnalyzeOperationOutput
} from "@azure-rest/​ai-document-intelligence";

const initialResponse = await client
  .path("/​documentModels/​{modelId}:analyze", "prebuilt-layout")
  .post({
    contentType: "application/​json",
    body: {
      urlSource: "https://example.com/​document.pdf"
    },
    queryParameters: { locale: "en-US" }
  });

if (isUnexpected(initialResponse)) {
  throw initialResponse.body.error;
}

const poller = getLongRunningPoller(client, initialResponse);
const result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;

console.log("Pages:", result.analyzeResult?.pages?.length);
console.log("Tables:", result.analyzeResult?.tables?.length);

Analyze Document (Local File)

import { readFile } from "node:fs/​promises";

const fileBuffer = await readFile("./​document.pdf");
const base64Source = fileBuffer.toString("base64");

const initialResponse = await client
  .path("/​documentModels/​{modelId}:analyze", "prebuilt-invoice")
  .post({
    contentType: "application/​json",
    body: { base64Source }
  });

if (isUnexpected(initialResponse)) {
  throw initialResponse.body.error;
}

const poller = getLongRunningPoller(client, initialResponse);
const result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;

Prebuilt Models

Model IDDescription
prebuilt-readOCR - text and language extraction
prebuilt-layoutText, tables, selection marks, structure
prebuilt-invoiceInvoice fields
prebuilt-receiptReceipt fields
prebuilt-idDocumentID document fields
prebuilt-tax.us.w2W-2 tax form fields
prebuilt-healthInsuranceCard.usHealth insurance card fields
prebuilt-contractContract fields
prebuilt-bankStatement.usBank statement fields

Extract Invoice Fields

const initialResponse = await client
  .path("/​documentModels/​{modelId}:analyze", "prebuilt-invoice")
  .post({
    contentType: "application/​json",
    body: { urlSource: invoiceUrl }
  });

if (isUnexpected(initialResponse)) {
  throw initialResponse.body.error;
}

const poller = getLongRunningPoller(client, initialResponse);
const result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;

const invoice = result.analyzeResult?.documents?.[0];
if (invoice) {
  console.log("Vendor:", invoice.fields?.VendorName?.content);
  console.log("Total:", invoice.fields?.InvoiceTotal?.content);
  console.log("Due Date:", invoice.fields?.DueDate?.content);
}

Extract Receipt Fields

const initialResponse = await client
  .path("/​documentModels/​{modelId}:analyze", "prebuilt-receipt")
  .post({
    contentType: "application/​json",
    body: { urlSource: receiptUrl }
  });

const poller = getLongRunningPoller(client, initialResponse);
const result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;

const receipt = result.analyzeResult?.documents?.[0];
if (receipt) {
  console.log("Merchant:", receipt.fields?.MerchantName?.content);
  console.log("Total:", receipt.fields?.Total?.content);
  
  for (const item of receipt.fields?.Items?.values || []) {
    console.log("Item:", item.properties?.Description?.content);
    console.log("Price:", item.properties?.TotalPrice?.content);
  }
}

List Document Models

import DocumentIntelligence, { isUnexpected, paginate } from "@azure-rest/​ai-document-intelligence";

const response = await client.path("/​documentModels").get();

if (isUnexpected(response)) {
  throw response.body.error;
}

for await (const model of paginate(client, response)) {
  console.log(model.modelId);
}

Build Custom Model

const initialResponse = await client.path("/​documentModels:build").post({
  body: {
    modelId: "my-custom-model",
    desc

More skills from ranbot-ai

react-modernization logo
ranbot-ai/awesome-skills

react-modernization

Master React version upgrades, class to hooks migration, concurrent features adoption, and codemods for automated transformation.

6 1
View
cicd-automation-workflow-automate logo
ranbot-ai/awesome-skills

cicd-automation-workflow-automate

You are a workflow automation expert specializing in creating efficient CI/CD pipelines, GitHub Actions workflows, and automated development processes. Design and implement automation that reduces man

6 1
View
conductor-manage logo
ranbot-ai/awesome-skills

conductor-manage

Manage track lifecycle: archive, restore, delete, rename, and cleanup

6 0
View
c-pro logo
ranbot-ai/awesome-skills

c-pro

Write efficient C code with proper memory management, pointer

6 0
View
clerk-auth logo
ranbot-ai/awesome-skills

clerk-auth

Expert patterns for Clerk auth implementation, middleware, organizations, webhooks, and user sync

6 0
View
mezmo-automation logo
ranbot-ai/awesome-skills

mezmo-automation

Automate Mezmo tasks via Rube MCP (Composio). Always search tools first for current schemas.

6 0
View
fp-types-ref logo
ranbot-ai/awesome-skills

fp-types-ref

Quick reference for fp-ts types. Use when user asks which type to use, needs Option/Either/Task decision help, or wants fp-ts imports.

6 0
View
google-calendar-automation logo
ranbot-ai/awesome-skills

google-calendar-automation

Lightweight Google Calendar integration with standalone OAuth authentication. No MCP server required.

6 0
View
scala-pro logo
ranbot-ai/awesome-skills

scala-pro

Master enterprise-grade Scala development with functional programming, distributed systems, and big data processing. Expert in Apache Pekko, Akka, Spark, ZIO/Cats Effect, and reactive architectures.

6 0
View
python-development-python-scaffold logo
ranbot-ai/awesome-skills

python-development-python-scaffold

You are a Python project architecture expert specializing in scaffolding production-ready Python applications. Generate complete project structures with modern tooling (uv, FastAPI, Django), type hint

6 0
View
onedesk-automation logo
ranbot-ai/awesome-skills

onedesk-automation

Automate Onedesk tasks via Rube MCP (Composio). Always search tools first for current schemas.

6 0
View
googlecalendar-automation logo
ranbot-ai/awesome-skills

googlecalendar-automation

Automate Google Calendar tasks via Rube MCP (Composio). Always search tools first for current schemas.

6 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View