Skip to main content
Autype Lens is a suite of AI-powered endpoints for document understanding. Under the hood, Lens combines modified open-source models to provide both stability and comprehensive functionality for processing PDFs, DOCX, ODT, and Markdown files. All Lens endpoints follow the standard tools job workflow: upload a file, create a job, poll for completion, read the result.

Endpoints

EndpointDescriptionCost
POST /tools/lens/ocrExtract text from a document4 credits per page
POST /tools/lens/generate-filenameGenerate a structured filename4 credits (flat)
POST /tools/lens/classifyClassify a document into categories4 credits (flat)
POST /tools/lens/extractExtract structured data from a document3 credits per page

Supported file types

All Lens endpoints accept the following file types:
FormatMIME type
PDFapplication/pdf
DOCXapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
ODTapplication/vnd.oasis.opendocument.text
Markdowntext/markdown

Limits

LimitValue
Maximum file size50 MB
Maximum pages processed (extract)50 pages
Maximum categories (classify)50
Minimum categories (classify)2
Maximum fields (extract)30
OCR output formats mdd and jsonPDF only
Page selection (pages parameter)PDF only

OCR

Extract text from a document. Returns the document content as Markdown.

Output formats

FormatDescriptionSupported input
mdStandard Markdown — raw text extractionPDF, DOCX, ODT, Markdown
mddAutype extended Markdown with document settings, defaults, header/footerPDF only
jsonFull Autype document JSON with sections and elementsPDF only
The mdd and json output formats are only available for PDF files. For DOCX, ODT, and Markdown files, use md.

Page selection

For PDF files with md output format, you can optionally select specific pages using the pages parameter:
{
  "fileId": "your-file-id",
  "outputFormat": "md",
  "pages": ["1", "3-5", "10-"]
}
Page spec syntax:
  • "3" — single page
  • "2-5" — page range (inclusive)
  • "10-" — from page 10 to end
If pages is omitted, all pages are processed.

Example request

curl -X POST https://api.autype.com/api/v1/dev/tools/lens/ocr \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fileId": "your-file-id",
    "outputFormat": "md"
  }'

Example result

{
  "id": "job-id",
  "action": "lens.ocr",
  "status": "COMPLETED",
  "result": {
    "outputFormat": "md",
    "content": "# Invoice\n\nInvoice Number: INV-2026-001\nDate: 2026-03-15\n\n| Item | Amount |\n|------|--------|\n| Service A | €500.00 |\n| Service B | €250.00 |\n\n**Total: €750.00**"
  }
}

Cost

4 credits per page processed. For DOCX, ODT, and Markdown files, cost is always 4 credits (counted as 1 page).

Generate Filename

Generate a structured filename for a document based on a naming schema with placeholders. The AI reads the document and fills in the placeholder values.

Request

{
  "fileId": "your-file-id",
  "filenameSchema": "invoice-{invoiceNr}-{dateCreated}"
}
PropertyTypeRequiredDescription
fileIdstringYesFile ID of the uploaded document.
filenameSchemastringYesFilename template with {placeholder} tags.
webhookobjectNoOptional webhook configuration.

Example result

{
  "id": "job-id",
  "action": "lens.generate-filename",
  "status": "COMPLETED",
  "result": {
    "generatedFilename": "invoice-INV-2026-001-2026-03-15",
    "placeholders": {
      "invoiceNr": "INV-2026-001",
      "dateCreated": "2026-03-15"
    }
  }
}
If a placeholder value cannot be found in the document, it is replaced with unknown.

Cost

4 credits per request (flat, regardless of page count).

Classify

Classify a document into one of the provided categories. The AI reads the first 3 pages of the document and picks the best matching category.

Request

{
  "fileId": "your-file-id",
  "categories": ["Invoice", "Contract", "Offer", "Delivery Note", "Other"]
}
PropertyTypeRequiredDescription
fileIdstringYesFile ID of the uploaded document.
categoriesstring[]YesArray of category names (min 2, max 50).
webhookobjectNoOptional webhook configuration.

Example result

{
  "id": "job-id",
  "action": "lens.classify",
  "status": "COMPLETED",
  "result": {
    "category": "Invoice",
    "confidence": 0.95,
    "reasoning": "The document contains an invoice number, line items with prices, and a total amount, which are characteristic of an invoice."
  }
}

Result fields

FieldTypeDescription
categorystringThe selected category — always one of the provided categories.
confidencenumberConfidence score between 0 and 1.
reasoningstringBrief explanation of why this category was chosen.

Edge cases

  • Empty document: Returns the first category with confidence: 0 and a message indicating the document is empty.
  • No clear match: The closest category is returned with a low confidence score.
  • The AI will never invent new categories — it always picks from the provided list.

Cost

4 credits per request (flat, regardless of page count).

Extract

Extract structured data from a document based on a user-defined field schema. Define field names, types, and optional descriptions. The AI reads the document and returns a JSON object with the extracted values.

Request

{
  "fileId": "your-file-id",
  "fields": {
    "invoiceNumber": {
      "type": "string",
      "description": "The invoice number, usually in format INV-XXXX"
    },
    "totalAmount": {
      "type": "number",
      "description": "Total amount including VAT"
    },
    "invoiceDate": {
      "type": "date",
      "description": "Date the invoice was issued"
    },
    "isPaid": {
      "type": "boolean"
    },
    "lineItems": {
      "type": "array",
      "description": "List of line items with description and amount"
    }
  },
  "pages": ["1-2"]
}
PropertyTypeRequiredDescription
fileIdstringYesFile ID of the uploaded document.
fieldsobjectYesField definitions (min 1, max 30). Each key is a field name, value defines type and optional description.
pagesstring[]NoPage selection for PDFs (same syntax as OCR). If omitted, up to 50 pages are processed.
webhookobjectNoOptional webhook configuration.

Field types

TypeDescriptionExample value
stringText value"INV-2026-001"
numberNumeric value750.00
booleanTrue/falsetrue
dateDate value"2026-03-15"
arrayList of values[{"description": "Service A", "amount": 500}]
Adding a description to a field helps the AI understand what to look for and significantly improves extraction accuracy.

Example result

{
  "id": "job-id",
  "action": "lens.extract",
  "status": "COMPLETED",
  "result": {
    "data": {
      "invoiceNumber": "INV-2026-001",
      "totalAmount": 750.00,
      "invoiceDate": "2026-03-15",
      "isPaid": false,
      "lineItems": [
        { "description": "Service A", "amount": 500.00 },
        { "description": "Service B", "amount": 250.00 }
      ]
    },
    "fieldsMissing": []
  }
}

Result fields

FieldTypeDescription
dataobjectExtracted values. Keys match the field names from the request.
fieldsMissingstring[]List of field names that could not be found in the document (values set to null).

Edge cases

  • Field not found: The field is set to null and its name is added to fieldsMissing.
  • Empty document: All fields are returned as null and all field names appear in fieldsMissing.
  • PDF exceeds 50 pages: Only the first 50 pages are processed when no pages parameter is specified.

Cost

3 credits per page processed. For DOCX, ODT, and Markdown files, cost is always 3 credits (counted as 1 page). Minimum cost is 3 credits.

General workflow

All Lens endpoints follow the same async job pattern:

1. Upload the document

curl -X POST https://api.autype.com/api/v1/dev/tools/files/upload \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@document.pdf"

2. Create a Lens job

curl -X POST https://api.autype.com/api/v1/dev/tools/lens/classify \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fileId": "your-file-id",
    "categories": ["Invoice", "Contract", "Report"]
  }'

3. Poll for completion

curl https://api.autype.com/api/v1/dev/tools/jobs/{jobId} \
  -H "X-API-Key: YOUR_API_KEY"
Poll until status is COMPLETED or FAILED. Alternatively, use a webhook to receive a notification when the job finishes.

4. Read the result

The result is returned directly in the job response under the result field — there is no separate file to download. This applies to all Lens endpoints.
Unlike PDF tool jobs (merge, split, etc.), Lens jobs return structured data in the result field instead of producing an output file. You do not need to call the download endpoint.