← Back to Blog

How to Run an AI OCR Document Reader Agent with OE Runtime

Extract text from scanned documents, invoices, receipts, and forms automatically. OE Runtime uses Azure Vision to run OCR, classifies the document type, and structures the extracted data into ready-to-use fields — no manual data entry required.

👁️
Step 1
Extract Text
Run OCR on the image and extract all visible text preserving reading order and layout.
Step 2
Classify & Structure
Identify the document type and extract structured fields like vendor, date, line items, or totals.
Step 3
Report
Return document type, extracted fields, full raw text, low-confidence regions, and suggested next action.

The Agent YAML

Create a file called agent.yaml inside an ocr-vision/ directory:

name: Document Reader
description: Extract and analyze text from images using OCR
instructions: |
  You are a document analysis agent. Extract text from images using OCR,
  then analyze, classify, and summarize the extracted content.
  Complete all steps fully before writing your report.
steps:
  - name: Extract Text
    content: |
      Call the Azure Vision connector to run OCR on the provided image.
      POST /read/analyze with body:
      {
        "url": "<image URL to analyze>"
      }
      Save the Operation-Location URL from the response headers.
      Then poll GET <operation-path> (the path portion of the Operation-Location URL)
      every 2 seconds until status is "succeeded".
      Extract all text lines from the analyzeResult.readResults.
  - name: Classify and Structure
    content: |
      Analyze the extracted text to determine the document type
      (invoice, receipt, contract, ID, form, letter, or other).
      Extract key structured fields based on type — e.g. for an invoice: vendor, date, line items, total.
  - name: Report
    content: |
      Produce a document analysis result:
      - Document type identified
      - Structured fields extracted with values
      - Full raw text extracted
      - Any low-confidence regions or unreadable sections
      - Suggested next action (e.g. file, process payment, follow up)
connectors:
  - connection_name: Azure Vision
    connection_type: azure-vision

The Config File

Create oe-config.json in the same directory:

{
  "llm": {
    "provider": "openai",
    "model": "gpt-4o",
    "apiKey": "YOUR_OPENAI_API_KEY"
  },
  "server": {
    "enabled": false,
    "port": 3333,
    "apiKey": "your-secret-api-key"
  },
  "connectors": [
    {
      "connection_name": "Azure Vision",
      "connection_type": "azure-vision",
      "apiKey": "YOUR_AZURE_VISION_KEY",
      "headerName": "Ocp-Apim-Subscription-Key",
      "baseUrl": "https://YOUR_RESOURCE.cognitiveservices.azure.com/vision/v3.2"
    }
  ]
}

Create an Azure Computer Vision resource at portal.azure.com and copy the endpoint and API key from the resource's Keys and Endpoint page. The free tier (F0) allows up to 5,000 OCR transactions per month.

Download OE Runtime

OE Runtime — Direct Downloads

Run the Agent

Windows

oe-runtime-win.exe ocr-vision/agent.yaml --config ocr-vision/oe-config.json

macOS

chmod +x oe-runtime-macos
oe-runtime-macos ocr-vision/agent.yaml --config ocr-vision/oe-config.json

Linux

chmod +x oe-runtime-linux
oe-runtime-linux ocr-vision/agent.yaml --config ocr-vision/oe-config.json

macOS Gatekeeper: On first run, macOS may block the binary. Go to System Settings → Privacy & Security → click "Allow Anyway" next to oe-runtime-macos.

Running as an API Server

Add --serve to start OE Runtime as an HTTP server on port 3333:

oe-runtime-win.exe --serve --config ocr-vision/oe-config.json

Then send a request:

curl -X POST http://localhost:3333/run \
  -H "Content-Type: application/json" \
  -d '{"yaml": "ocr-vision/agent.yaml", "params": {}}'

Or import the Postman collection (download above) to test all endpoints visually.

Use Cases

Build your own agents with OE Runtime

Download OE Runtime and run any AI agent locally or as a server — no cloud required.

Get OE Runtime →
Series OE Runtime Agent Guides — 21 Connectors
Series overview →