API Documentation
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:
Parameter | Type | Required | Description |
---|---|---|---|
document | object | Yes | Document object |
document.type | string | Yes | Fixed value "image_url" |
document.image_url | string | Yes | Image URL or base64 data |
result_schema | object/string | Yes | JSON Schema defining fields to extract |
filename | string | No | Filename (recommended for base64 data) |
key | string | No | API 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:
Parameter | Type | Description |
---|---|---|
id | string | Database record ID |
filename | string | Filename |
content | string | Extracted structured information (JSON string format) |
format | string | Output format, fixed as "json" |
timestamp | number | Processing completion timestamp |
payload | string | API 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"
}