API Documentation

Quick Start

Get your API key and start converting documents in minutes.

Get Started β†’

Key Information Extraction API

Extract structured information from invoices, certificates, and forms using custom JSON Schema, returns results in JSON format

Overview

The Key Information Extraction API extracts structured information from invoices, certificates, forms and other documents. You can define custom JSON Schema to specify which fields to extract, and the model will intelligently identify and fill in the corresponding information from the image in JSON format.

It uses a unified JSON request format, accepting either URL references or base64-encoded image data.

Authentication

The API supports the following authentication method:

  • API Key: Pass your API key as a query parameter ?key=YOUR_API_KEY

Extract Structured Information from Image

Extract structured information from image files using intelligent recognition technology with custom JSON Schema.

Request

POST /api/key-information-extraction

Parameters:

ParameterTypeRequiredDescription
documentobjectYesDocument object
document.typestringYesFixed value "image_url"
document.image_urlstringYesImage URL or base64 data
result_schemaobject/stringYesJSON Schema defining fields to extract
filenamestringNoFilename (recommended for base64 data)
keystringNoAPI key (query parameter, optional for logged-in users)

result_schema Notes:

  • Can be a JSON object or JSON string
  • Supports up to 3 levels of nesting
  • Only define keys (field names), keep values as empty strings
  • Supports array structures

Examples:

Using Image URL:

curl -X POST "https://llmocr.com/api/key-information-extraction?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "type": "image_url",
      "image_url": "https://llmocr.com/invoice.jpg"
    },
    "result_schema": {
      "Seller Name": "",
      "Buyer Name": "",
      "Price Excluding Tax": "",
      "Invoice Code": ""
    }
  }'

Using Base64 Image Data:

curl -X POST "https://llmocr.com/api/key-information-extraction?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "type": "image_url",
      "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA..."
    },
    "result_schema": {
      "Name": "",
      "ID Number": "",
      "Address": ""
    },
    "filename": "id-card.jpg"
  }'

Response

Parameters:

ParameterTypeDescription
idstringDatabase record ID
filenamestringFilename
contentstringExtracted structured information (JSON string format)
formatstringOutput format, fixed as "json"
timestampnumberProcessing completion timestamp
payloadstringAPI endpoint URL

Example:

{
  "id": "12345",
  "filename": "invoice.jpg",
  "content": "{\"Seller Name\":\"ABC Company Ltd\",\"Buyer Name\":\"John Doe\",\"Price Excluding Tax\":\"270000.00\",\"Invoice Code\":\"142011726001\"}",
  "format": "json",
  "timestamp": 1640995200000,
  "payload": "https://llmocr.com/api/key-information-extraction?key=YOUR_API_KEY"
}
Key Information Extraction API - LLMOCR Developer Guide