> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autype.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lens OCR

> Extract text from a document using AI. Supports PDF, DOCX, ODT, and Markdown files. Output formats: "md" (raw standard markdown), "mdd" (Autype extended markdown with document settings and defaults), "json" (full Autype document JSON with sections). For PDF files with "md" format you can optionally specify which pages to process. Cost: 4 credits per page.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/dev/tools/lens/ocr
openapi: 3.0.0
info:
  title: Autype Developer API
  description: >-
    Autype Developer API for programmatic document generation.


    ## Authentication

    All endpoints require an API key. Include it in the `X-API-Key` header or as
    a Bearer token.


    ## Rate Limiting

    API requests are rate-limited to 100 requests per minute per API key.


    ## Token Billing

    Rendering operations consume tokens from your organization's balance.
  version: '1.0'
  contact: {}
servers:
  - url: https://api.autype.com
    description: Production
security: []
tags:
  - name: Temporary Images
    description: Upload and manage temporary images for document rendering
  - name: Render
    description: Render documents to PDF, DOCX, or ODT
  - name: Bulk Render
    description: Bulk document generation with variable substitution
  - name: Documents
    description: Document variable inspection
  - name: Projects
    description: List organization projects
paths:
  /api/v1/dev/tools/lens/ocr:
    post:
      tags:
        - developer-api
      summary: Lens OCR
      description: >-
        Extract text from a document using AI. Supports PDF, DOCX, ODT, and
        Markdown files. Output formats: "md" (raw standard markdown), "mdd"
        (Autype extended markdown with document settings and defaults), "json"
        (full Autype document JSON with sections). For PDF files with "md"
        format you can optionally specify which pages to process. Cost: 4
        credits per page.
      operationId: ToolsController_lensOcr_v1
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LensOcrDto'
      responses:
        '201':
          description: Lens OCR job created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolsJobResponseDto'
      security:
        - api-key: []
components:
  schemas:
    LensOcrDto:
      type: object
      properties:
        fileId:
          type: string
          description: File ID of the document to process (PDF, DOCX, ODT, or Markdown)
          example: 550e8400-e29b-41d4-a716-446655440000
        pages:
          description: >-
            Page specifications (e.g. "1", "2-5", "3-"). If omitted, all pages
            are processed. Only applicable to PDF files with "md" output format.
          example:
            - '1'
            - 3-5
          type: array
          items:
            type: string
        outputFormat:
          type: string
          description: >-
            Output format. "md" returns raw standard markdown (Mistral OCR).
            "mdd" returns Autype extended markdown with document settings and
            defaults. "json" returns full Autype document JSON with sections.
            Note: "mdd" and "json" formats are only supported for PDF files —
            DOCX, ODT, and Markdown files always return "md" regardless of this
            setting.
          enum:
            - md
            - mdd
            - json
          example: md
        webhook:
          description: Optional webhook configuration
          allOf:
            - $ref: '#/components/schemas/WebhookConfigDto'
      required:
        - fileId
    ToolsJobResponseDto:
      type: object
      properties:
        id:
          type: string
          description: Job ID
          example: 550e8400-e29b-41d4-a716-446655440000
        action:
          type: string
          description: Action that was performed
          example: pdf.merge
        status:
          type: string
          description: Current job status
          enum:
            - PENDING
            - PROCESSING
            - COMPLETED
            - FAILED
          example: PENDING
        inputFileIds:
          description: Input file IDs used for this job
          example:
            - file-id-1
          type: array
          items:
            type: string
        outputFileId:
          type: object
          description: Output file ID (available when COMPLETED)
          nullable: true
          example: null
        error:
          type: object
          description: Error message (available when FAILED)
          nullable: true
          example: null
        result:
          type: object
          description: >-
            Structured job result data (e.g. OCR markdown/JSON, generated
            filename, PDF metadata, form fields). Available when the job
            produces a direct result instead of an output file.
        metadata:
          type: object
          description: >-
            **Deprecated** — use `result` instead. Additional metadata,
            duplicated from result for backward compatibility.
          deprecated: true
        createdAt:
          format: date-time
          type: string
          description: Job creation timestamp
        startedAt:
          type: object
          description: Job start timestamp
          nullable: true
        completedAt:
          type: object
          description: Job completion timestamp
          nullable: true
      required:
        - id
        - action
        - status
        - inputFileIds
        - outputFileId
        - error
        - createdAt
        - startedAt
        - completedAt
    WebhookConfigDto:
      type: object
      properties:
        webhookUrl:
          type: string
          example: https://example.com/webhook
          description: URL to receive a POST notification when the job completes or fails
        webhookAuth:
          description: >-
            Optional authentication for the webhook request (custom header or
            Basic Auth)
          allOf:
            - $ref: '#/components/schemas/WebhookAuthDto'
    WebhookAuthDto:
      type: object
      properties:
        headerName:
          type: string
          example: X-API-Key
          description: Custom header name
        headerValue:
          type: string
          example: my-secret-key
          description: Custom header value
        basicAuthUsername:
          type: string
          example: user
          description: Username for Basic Auth
        basicAuthPassword:
          type: string
          example: pass
          description: Password for Basic Auth
  securitySchemes:
    api-key:
      type: apiKey
      in: header
      name: X-API-Key
      description: API Key (starts with ak_...)

````