LM-Kit OneDocs2026.8.10lm-kit.com
AI Extraction

Structured Extraction

Extract structured data from the input text, PDF, HTML, EML, MBOX, MS Office document or image.#

POST/lmkit/v1/extract-structured-data

Analyzes the provided content to extract structured data using the specified or default extraction model. Optional extraction parameters, such as additional guidance text and a JSON extraction scheme, can be provided. Returns the extracted structured data as a JSON representation defined in the response model. If processing exceeds the configured timeout, returns 202 Accepted with a job_id. Poll GET /lmkit/v1/jobs/ for status and results.

Request body

application/json ·

PropertyTypeDescription
modelstring

The identifier of the language model to be used for structured extraction. If not provided, the default model is used.

inputrequiredobject

Either a single string (plain text or Base64-encoded file).
- If a single string: set “input_format” to PlainText or Base64EncodedFile.
- If an array of strings: length must be even; each pair is “[imageFileBase64, associatedText]”
  • The first element of each pair is a Base64-encoded image file.
  • The second element is the text to associate with that image.
Sending pairs of [image, text] activates multimodal extraction (image + text).

input_format

The format of the input data. Only used when “input” is a single string.
Allowed: 'PlainText' or 'Base64EncodedFile'. Defaults to 'PlainText'.
For 'Base64EncodedFile', supported formats include HTML, PDF, XLSX, PPTX, DOCX, EML, MBOX, PNG, BMP, GIF, PSD, PIC, JPEG, PNM, HDR, TGA, WEBP, and TIFF.
Defaults to 'PlainText'.

jsonSchemarequired

Configures the text extraction elements by parsing a JSON schema.
This string defines the structure, types, and optional descriptions of the extraction elements.
The 'type' field in the JSON must correspond to one of the supported element types.
Allowed values are: char, string, integer, uint, short, ushort, long, ulong, bool, float, double, date, object, number, array.
Example:


{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Invoice",
  "description": "JSON schema for extracting and validating invoice data, including vendor, buyer, line items, and total amount.",
  "type": "object",
  "properties": {
    "invoice_number": {
      "type": "string",
      "trimStart": [ "INV/", "INV-", "INV", "INV#" ]
    },
    "invoice_date": {
      "type": "string",
      "format": "date"
    },
    "vendor": {
      "type": "object",
      "description": "Seller information.",
      "properties": {
        "name": { "type": "string" },
        "tax_registration_id": {
          "type": "string",
          "trimStart": [ "VAT", "TVA", "GSTIN/UIN" ]
        },
        "email": {
          "type": "string",
          "format": "email"
        }
      },
      "required": [ "name" ]
    },
    "bill_to": {
      "type": "object",
      "description": "Buyer information.",
      "properties": {
        "name": {
          "type": "string",
          "trimStart": [ "Monsieur ", "Madame ", "Prof ", "Doctor ", "Mrs ", "Mr ", "Ms ", "Mlle " ]
        },
        "street_address": { "type": "string" },
        "city": { "type": "string" },
        "state": { "type": "string" },
        "postal_code": { "type": "string" },
        "country": {
          "type": "string",
          "description": "Two-letter country code.",
          "enum": [ "DE", "FR", "US", "ES", "IN", "" ]
        },
        "phone": { "type": "string" },
        "email": {
          "type": "string",
          "format": "email"
        },
        "site": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [ "name", "street_address", "city", "state", "postal_code", "country" ]
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "description": { "type": "string" },
          "quantity": { "type": "number" },
          "unit_price_net": {
            "type": "number",
            "description": "Unit price without tax."
          },
          "total_price_gross": {
            "type": "number",
            "description": "Line total including tax."
          }
        },
        "required": [ "description", "quantity", "unit_price_net", "total_price_gross" ]
      }
    },
    "total_amount": {
      "type": "number",
      "description": "Total invoice amount including tax."
    }
  },
  "required": [ "invoice_number", "invoice_date", "vendor", "bill_to", "items", "total_amount" ]
}
  

enable_ocrboolean

Whether to use OCR for pages that contain no extractable text (e.g., scanned images). Requires an OCR provider to be configured on the server. Defaults to true.

guidancestring

Additional guidance text that can influence the extraction process (e.g., focusing on certain themes).

include_elementsboolean

Whether to include the per-field element details (confidence, entity validation, human-verification flag, page index and bounds) in the response. Defaults to false.

Responses

StatusTypeDescription
200

OK

202

Accepted

400

Bad Request

500application/json

Internal Server Error

404

Not Found

curl -X POST "$LMKIT_ONE_URL/lmkit/v1/extract-structured-data" \
  -H "Authorization: Bearer $LMKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "",
  "input": "",
  "input_format": "PlainText",
  "jsonSchema": {},
  "enable_ocr": true,
  "guidance": ""
}'