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

# Cross-Document Analysis

> Analyze and cross-reference multiple documents together. Unlike `/analyze` (single
document) or `/analyze/batch` (many documents independently), this endpoint lets
the agent reason **across** all documents simultaneously.

**Use cases**:
- Validate an invoice against a contract or purchase order
- Check that a report's numbers match a source spreadsheet
- Compare terms across multiple agreements
- Reconcile data from different sources

Upload 2-5 files and/or provide URLs. Each document gets a label (auto-generated
from filename, or you can provide custom labels). The agent can search, read, and
compare data across all documents.

Provide a typed schema — each field has a type and description.

**Example**:
```json
{
  "rates_match": {"type": "boolean", "description": "Do the hourly rates on the invoice match the contract?"},
  "total_valid": {"type": "boolean", "description": "Does the invoice total equal the sum of line items?"},
  "correct_vendor": {"type": "boolean", "description": "Is the vendor name on the invoice the same as the contracting party?"}
}
```

**Pricing**: 5 credits/document + 3 credits/page (minimum 10).



## OpenAPI

````yaml /openapi.json post /api/v1/analyze/cross
openapi: 3.1.0
info:
  title: The Drive AI API
  description: >

    ## The Drive AI API


    One API for screenshots, markdown extraction, structured data extraction,

    and more. 107+ file formats supported.


    ## Endpoints


    | Endpoint | Credits | Description |

    |----------|---------|-------------|

    | `GET /{url}` | 1 | Screenshot any URL |

    | `GET /md/{url}` | 1 | Convert any URL to markdown |

    | `POST /api/v1/thumbnails/generate` | 1 | Generate thumbnail from file or
    URL |

    | `POST /api/v1/markdown/convert` | 1 | Convert file/URL to markdown |

    | `POST /api/v1/extract` | 1/page or 5/site | Extract structured data |

    | `POST /api/v1/analyze` | 2/page or 10/site | Analyze — compute, reason,
    derive |


    ## Authentication


    All protected endpoints require an `X-API-Key` header:

    ```bash

    curl https://dev.thedrive.ai/stripe.com \
      -H "X-API-Key: tda_live_your_key_here"
    ```


    Get your API key at https://dev.thedrive.ai/login


    ## Pricing


    - **Free**: 100 credits/month, no card required

    - **Pro**: $0.01/credit, pay-as-you-go

    - **Enterprise**: Volume pricing, contact us
  version: 1.3.0
servers: []
security: []
tags:
  - name: screenshots
    description: Screenshot and thumbnail generation
  - name: markdown
    description: URL and document to markdown conversion
  - name: extraction
    description: Structured data extraction from documents
  - name: thumbnails
    description: Thumbnail generation via file upload or URL
  - name: health
    description: Service health and readiness probes
paths:
  /api/v1/analyze/cross:
    post:
      tags:
        - analysis
      summary: Cross-Document Analysis
      description: >-
        Analyze and cross-reference multiple documents together. Unlike
        `/analyze` (single

        document) or `/analyze/batch` (many documents independently), this
        endpoint lets

        the agent reason **across** all documents simultaneously.


        **Use cases**:

        - Validate an invoice against a contract or purchase order

        - Check that a report's numbers match a source spreadsheet

        - Compare terms across multiple agreements

        - Reconcile data from different sources


        Upload 2-5 files and/or provide URLs. Each document gets a label
        (auto-generated

        from filename, or you can provide custom labels). The agent can search,
        read, and

        compare data across all documents.


        Provide a typed schema — each field has a type and description.


        **Example**:

        ```json

        {
          "rates_match": {"type": "boolean", "description": "Do the hourly rates on the invoice match the contract?"},
          "total_valid": {"type": "boolean", "description": "Does the invoice total equal the sum of line items?"},
          "correct_vendor": {"type": "boolean", "description": "Is the vendor name on the invoice the same as the contracting party?"}
        }

        ```


        **Pricing**: 5 credits/document + 3 credits/page (minimum 10).
      operationId: cross_analyze_api_v1_analyze_cross_post
      parameters:
        - name: X-API-Key
          in: header
          required: false
          schema:
            type: string
            title: X-Api-Key
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_cross_analyze_api_v1_analyze_cross_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CrossAnalyzeResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: File too large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Analysis or extraction failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: AI service unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '504':
          description: Analysis timed out
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Body_cross_analyze_api_v1_analyze_cross_post:
      properties:
        files:
          items:
            type: string
            contentMediaType: application/octet-stream
          type: array
          title: Files
          description: Files to analyze (2-5). Labeled by filename or via document_labels.
          default: []
        urls:
          anyOf:
            - type: string
            - type: 'null'
          title: Urls
          description: >-
            JSON array of URLs, or JSON object mapping labels to URLs (e.g.
            {"invoice": "https://..."}). Combined with files, total must be 2-5.
        url_headers:
          anyOf:
            - type: string
            - type: 'null'
          title: Url Headers
          description: JSON-encoded headers for URL auth
        schema:
          type: string
          title: Schema
          description: >-
            JSON schema — keys are field names, values describe what to validate
            or compute across documents
        document_labels:
          anyOf:
            - type: string
            - type: 'null'
          title: Document Labels
          description: >-
            JSON array of labels for the uploaded files, in order. Must match
            files count. E.g. ["invoice", "contract"]
        include_steps:
          type: boolean
          title: Include Steps
          description: Include the agent's reasoning trace in each answer
          default: false
        sync:
          type: boolean
          title: Sync
          description: Set to false to process asynchronously. Returns a task_id to poll.
          default: true
        webhook_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Webhook Url
          description: URL to POST the result to when async processing completes.
      type: object
      required:
        - schema
      title: Body_cross_analyze_api_v1_analyze_cross_post
    CrossAnalyzeResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        data:
          additionalProperties: true
          type: object
          title: Data
          description: Computed/derived values keyed by field name
        confidence:
          additionalProperties:
            type: number
          type: object
          title: Confidence
          description: Per-field confidence scores (0.0–1.0)
        sources:
          additionalProperties:
            items:
              type: string
            type: array
          type: object
          title: Sources
          description: Per-field source text snippets (prefixed with [doc_label])
        reasoning:
          additionalProperties:
            type: string
          type: object
          title: Reasoning
          description: Per-field step-by-step explanation referencing specific documents
        steps:
          additionalProperties:
            items:
              $ref: '#/components/schemas/AgentStepResponse'
            type: array
          type: object
          title: Steps
          description: Per-field agent reasoning trace. Empty unless include_steps=true.
        documents:
          items:
            $ref: '#/components/schemas/DocumentInfo'
          type: array
          title: Documents
          description: Metadata for each document in the analysis
        model_used:
          type: string
          title: Model Used
          description: Model used for analysis
        total_text_length:
          type: integer
          title: Total Text Length
          description: Combined text length across all documents
        total_pages:
          type: integer
          title: Total Pages
          description: Combined page count across all documents
        credits_used:
          type: integer
          title: Credits Used
          description: Credits consumed
          default: 0
        schema_format:
          anyOf:
            - $ref: '#/components/schemas/SchemaFormat'
            - type: 'null'
          description: 'Schema format: always ''typed'''
      type: object
      required:
        - data
        - documents
        - model_used
        - total_text_length
        - total_pages
      title: CrossAnalyzeResponse
      description: >-
        Response for cross-document analysis — flat parallel dicts matching
        /extract.
      example:
        confidence:
          rates_match: 0.95
        credits_used: 35
        data:
          rates_match: false
        documents:
          - content_type: application/pdf
            filename: invoice_042.pdf
            label: invoice
            text_length: 1200
            total_pages: 2
          - content_type: application/pdf
            filename: service_agreement.pdf
            label: contract
            text_length: 15000
            total_pages: 8
        model_used: gpt-5.1
        reasoning:
          rates_match: Invoice hourly rate ($150) differs from contract rate ($125)
        sources:
          rates_match:
            - '[invoice] "Rate: $150.00/hr"'
            - '[contract] "Hourly rate: $125.00"'
        success: true
        total_pages: 10
        total_text_length: 16200
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: false
        error:
          type: string
          title: Error
          description: Error type
        detail:
          type: string
          title: Detail
          description: Human-readable error message
      type: object
      required:
        - error
        - detail
      title: ErrorResponse
      description: Standard error response.
      example:
        detail: File size exceeds maximum allowed (50MB)
        error: validation_error
        success: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentStepResponse:
      properties:
        tool:
          type: string
          title: Tool
          description: Tool that was called
        args:
          additionalProperties: true
          type: object
          title: Args
          description: Arguments passed to the tool
        result_preview:
          type: string
          title: Result Preview
          description: First 200 chars of the tool output
          default: ''
      type: object
      required:
        - tool
      title: AgentStepResponse
      description: One step in the agent's reasoning trace.
    DocumentInfo:
      properties:
        label:
          type: string
          title: Label
          description: Document label used in the analysis
        filename:
          type: string
          title: Filename
          description: Original filename or URL
        content_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Type
          description: Detected MIME type
        total_pages:
          type: integer
          title: Total Pages
          description: Number of pages in this document
          default: 0
        text_length:
          type: integer
          title: Text Length
          description: Length of extracted text
          default: 0
      type: object
      required:
        - label
        - filename
      title: DocumentInfo
      description: Metadata about one document in a cross-document analysis.
    SchemaFormat:
      type: string
      enum:
        - typed
      title: SchemaFormat
      description: Schema format used for extraction/analysis.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````