← 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: |
      Run OCR on the image provided via the Azure Vision connector.
      Extract all visible text — preserve the reading order and layout as closely as possible.
      Note any regions where text confidence is low.
  - 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",
      "endpoint": "https://YOUR_RESOURCE.cognitiveservices.azure.com",
      "apiKey": "YOUR_AZURE_VISION_KEY"
    }
  ]
}

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

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

macOS

# Make executable (first time only)
chmod +x oe-runtime-macos

# Run the agent
oe-runtime-macos ocr-vision/agent.yaml --config ocr-vision/oe-config.json

Linux

# Make executable (first time only)
chmod +x oe-runtime-linux

# Run the agent
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 →