{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/azure-ai-document-intelligence-ts",
  "version": "1.0.0",
  "name": "Azure Ai Document Intelligence Ts",
  "description": "Extract text, tables, and structured data from documents using Azure Document Intelligence (@azure-rest/ai-document-intelligence). Use when processing invoices, receipts, IDs, forms, or building cu...",
  "system_prompt_fragment": "# Azure Document Intelligence REST SDK for TypeScript\n\nExtract text, tables, and structured data from documents using prebuilt and custom models.\n\n## Installation\n\n```bash\nnpm install @azure-rest/ai-document-intelligence @azure/identity\n```\n\n## Environment Variables\n\n```bash\nDOCUMENT_INTELLIGENCE_ENDPOINT=https://<resource>.cognitiveservices.azure.com\nDOCUMENT_INTELLIGENCE_API_KEY=<api-key>\n```\n\n## Authentication\n\n**Important**: This is a REST client. `DocumentIntelligence` is a **function**, not a class.\n\n### DefaultAzureCredential\n\n```typescript\nimport DocumentIntelligence from \"@azure-rest/ai-document-intelligence\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\n\nconst client = DocumentIntelligence(\n  process.env.DOCUMENT_INTELLIGENCE_ENDPOINT!,\n  new DefaultAzureCredential()\n);\n```\n\n### API Key\n\n```typescript\nimport DocumentIntelligence from \"@azure-rest/ai-document-intelligence\";\n\nconst client = DocumentIntelligence(\n  process.env.DOCUMENT_INTELLIGENCE_ENDPOINT!,\n  { key: process.env.DOCUMENT_INTELLIGENCE_API_KEY! }\n);\n```\n\n## Analyze Document (URL)\n\n```typescript\nimport DocumentIntelligence, {\n  isUnexpected,\n  getLongRunningPoller,\n  AnalyzeOperationOutput\n} from \"@azure-rest/ai-document-intelligence\";\n\nconst initialResponse = await client\n  .path(\"/documentModels/{modelId}:analyze\", \"prebuilt-layout\")\n  .post({\n    contentType: \"application/json\",\n    body: {\n      urlSource: \"https://example.com/document.pdf\"\n    },\n    queryParameters: { locale: \"en-US\" }\n  });\n\nif (isUnexpected(initialResponse)) {\n  throw initialResponse.body.error;\n}\n\nconst poller = getLongRunningPoller(client, initialResponse);\nconst result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;\n\nconsole.log(\"Pages:\", result.analyzeResult?.pages?.length);\nconsole.log(\"Tables:\", result.analyzeResult?.tables?.length);\n```\n\n## Analyze Document (Local File)\n\n```typescript\nimport { readFile } from \"node:fs/promises\";\n\nconst fileBuffer = await readFile(\"./document.pdf\");\nconst base64Source = fileBuffer.toString(\"base64\");\n\nconst initialResponse = await client\n  .path(\"/documentModels/{modelId}:analyze\", \"prebuilt-invoice\")\n  .post({\n    contentType: \"application/json\",\n    body: { base64Source }\n  });\n\nif (isUnexpected(initialResponse)) {\n  throw initialResponse.body.error;\n}\n\nconst poller = getLongRunningPoller(client, initialResponse);\nconst result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;\n```\n\n## Prebuilt Models\n\n| Model ID | Description |\n|----------|-------------|\n| `prebuilt-read` | OCR - text and language extraction |\n| `prebuilt-layout` | Text, tables, selection marks, structure |\n| `prebuilt-invoice` | Invoice fields |\n| `prebuilt-receipt` | Receipt fields |\n| `prebuilt-idDocument` | ID document fields |\n| `prebuilt-tax.us.w2` | W-2 tax form fields |\n| `prebuilt-healthInsuranceCard.us` | Health insurance card fields |\n| `prebuilt-contract` | Contract fields |\n| `prebuilt-bankStatement.us` | Bank statement fields |\n\n## Extract Invoice Fields\n\n```typescript\nconst initialResponse = await client\n  .path(\"/documentModels/{modelId}:analyze\", \"prebuilt-invoice\")\n  .post({\n    contentType: \"application/json\",\n    body: { urlSource: invoiceUrl }\n  });\n\nif (isUnexpected(initialResponse)) {\n  throw initialResponse.body.error;\n}\n\nconst poller = getLongRunningPoller(client, initialResponse);\nconst result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;\n\nconst invoice = result.analyzeResult?.documents?.[0];\nif (invoice) {\n  console.log(\"Vendor:\", invoice.fields?.VendorName?.content);\n  console.log(\"Total:\", invoice.fields?.InvoiceTotal?.content);\n  console.log(\"Due Date:\", invoice.fields?.DueDate?.content);\n}\n```\n\n## Extract Receipt Fields\n\n```typescript\nconst initialResponse = await client\n  .path(\"/documentModels/{modelId}:analyze\", \"prebuilt-receipt\")\n  .post({\n    contentType: \"application/json\",\n    body: { urlSource: receiptUrl }\n  });\n\nconst poller = getLongRunningPoller(client, initialResponse);\nconst result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;\n\nconst receipt = result.analyzeResult?.documents?.[0];\nif (receipt) {\n  console.log(\"Merchant:\", receipt.fields?.MerchantName?.content);\n  console.log(\"Total:\", receipt.fields?.Total?.content);\n  \n  for (const item of receipt.fields?.Items?.values || []) {\n    console.log(\"Item:\", item.properties?.Description?.content);\n    console.log(\"Price:\", item.properties?.TotalPrice?.content);\n  }\n}\n```\n\n## List Document Models\n\n```typescript\nimport DocumentIntelligence, { isUnexpected, paginate } from \"@azure-rest/ai-document-intelligence\";\n\nconst response = await client.path(\"/documentModels\").get();\n\nif (isUnexpected(response)) {\n  throw response.body.error;\n}\n\nfor await (const model of paginate(client, response)) {\n  console.log(model.modelId);\n}\n```\n\n## Build Custom Model\n\n```typescript\nconst initialResponse = await client.path(\"/documentModels:build\").post({\n  body: {\n    modelId: \"my-custom-model\",\n    description: \"Custom model for purchase orders\",\n    buildMode: \"template\",  // or \"neural\"\n    azureBlobSource: {\n      containerUrl: process.env.TRAINING_CONTAINER_SAS_URL!,\n      prefix: \"training-data/\"\n    }\n  }\n});\n\nif (isUnexpected(initialResponse)) {\n  throw initialResponse.body.error;\n}\n\nconst poller = getLongRunningPoller(client, initialResponse);\nconst result = await poller.pollUntilDone();\nconsole.log(\"Model built:\", result.body);\n```\n\n## Build Document Classifier\n\n```typescript\nimport { DocumentClassifierBuildOperationDetailsOutput } from \"@azure-rest/ai-document-intelligence\";\n\nconst containerSasUrl = process.env.TRAINING_CONTAINER_SAS_URL!;\n\nconst initialResponse = await client.path(\"/documentClassifiers:build\").post({\n  body: {\n    classifierId: \"my-classifier\",\n    description: \"Invoice vs Receipt classifier\",\n    docTypes: {\n      invoices: {\n        azureBlobSource: { containerUrl: containerSasUrl, prefix: \"invoices/\" }\n      },\n      receipts: {\n        azureBlobSource: { containerUrl: containerSasUrl, prefix: \"receipts/\" }\n      }\n    }\n  }\n});\n\nif (isUnexpected(initialResponse)) {\n  throw initialResponse.body.error;\n}\n\nconst poller = getLongRunningPoller(client, initialResponse);\nconst result = (await poller.pollUntilDone()).body as DocumentClassifierBuildOperationDetailsOutput;\nconsole.log(\"Classifier:\", result.result?.classifierId);\n```\n\n## Classify Document\n\n```typescript\nconst initialResponse = await client\n  .path(\"/documentClassifiers/{classifierId}:analyze\", \"my-classifier\")\n  .post({\n    contentType: \"application/json\",\n    body: { urlSource: documentUrl },\n    queryParameters: { split: \"auto\" }\n  });\n\nif (isUnexpected(initialResponse)) {\n  throw initialResponse.body.error;\n}\n\nconst poller = getLongRunningPoller(client, initialResponse);\nconst result = await poller.pollUntilDone();\nconsole.log(\"Classification:\", result.body.analyzeResult?.documents);\n```\n\n## Get Service Info\n\n```typescript\nconst response = await client.path(\"/info\").get();\n\nif (isUnexpected(response)) {\n  throw response.body.error;\n}\n\nconsole.log(\"Custom model limit:\", response.body.customDocumentModels.limit);\nconsole.log(\"Custom model count:\", response.body.customDocumentModels.count);\n```\n\n## Polling Pattern\n\n```typescript\nimport DocumentIntelligence, {\n  isUnexpected,\n  getLongRunningPoller,\n  AnalyzeOperationOutput\n} from \"@azure-rest/ai-document-intelligence\";\n\n// 1. Start operation\nconst initialResponse = await client\n  .path(\"/documentModels/{modelId}:analyze\", \"prebuilt-layout\")\n  .post({ contentType: \"application/json\", body: { urlSource } });\n\n// 2. Check for errors\nif (isUnexpected(initialResponse)) {\n  throw initialResponse.body.error;\n}\n\n// 3. Create poller\nconst poller = getLongRunningPoller(client, initialResponse);\n\n// 4. Optional: Monitor progress\npoller.onProgress((state) => {\n  console.log(\"Status:\", state.status);\n});\n\n// 5. Wait for completion\nconst result = (await poller.pollUntilDone()).body as AnalyzeOperationOutput;\n```\n\n## Key Types\n\n```typescript\nimport DocumentIntelligence, {\n  isUnexpected,\n  getLongRunningPoller,\n  paginate,\n  parseResultIdFromResponse,\n  AnalyzeOperationOutput,\n  DocumentClassifierBuildOperationDetailsOutput\n} from \"@azure-rest/ai-document-intelligence\";\n```\n\n## Best Practices\n\n1. **Use getLongRunningPoller()** - Document analysis is async, always poll for results\n2. **Check isUnexpected()** - Type guard for proper error handling\n3. **Choose the right model** - Use prebuilt models when possible, custom for specialized docs\n4. **Handle confidence scores** - Fields have confidence values, set thresholds for your use case\n5. **Use pagination** - Use `paginate()` helper for listing models\n6. **Prefer neural mode** - For custom models, neural handles more variation than template\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.",
  "applicable_domains": [
    "devops"
  ],
  "category": "devops",
  "invocation": [
    "/azure-ai-document-intelligence-ts"
  ],
  "authored_by": "claudeskills.in community",
  "source_url": "https://claudeskills.in/skill/azure-ai-document-intelligence-ts",
  "provenance": {
    "source": "claudeskills.in",
    "source_url": "https://claudeskills.in/skill/azure-ai-document-intelligence-ts",
    "license": "unknown",
    "imported_at": "2026-09-03",
    "notes": "Aggregated by claudeskills.in from community GitHub lists."
  },
  "tags": [
    "claudeskills",
    "devops"
  ],
  "lifecycle": "draft"
}