> ## 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.

# Generate Thumbnail

> Generate a thumbnail from a file upload or URL.

**File Upload**: Use multipart/form-data with a `file` field.

**URL Fetch**: Use JSON body with `url` field. Optionally include `url_headers` for authenticated URLs.

**Options**:
- `width`, `height`: Max dimensions (default 600x400)
- `quality`: JPEG quality 1-100 (default 95)
- `sync`: Wait for result (true) or return job ID (false)
- `webhook_url`: URL to POST result when complete (async only)
- `response_type`: "url" returns storage URL, "base64" returns encoded image



## OpenAPI

````yaml /openapi.json post /api/v1/thumbnails/generate
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/thumbnails/generate:
    post:
      tags:
        - thumbnails
      summary: Generate Thumbnail
      description: >-
        Generate a thumbnail from a file upload or URL.


        **File Upload**: Use multipart/form-data with a `file` field.


        **URL Fetch**: Use JSON body with `url` field. Optionally include
        `url_headers` for authenticated URLs.


        **Options**:

        - `width`, `height`: Max dimensions (default 600x400)

        - `quality`: JPEG quality 1-100 (default 95)

        - `sync`: Wait for result (true) or return job ID (false)

        - `webhook_url`: URL to POST result when complete (async only)

        - `response_type`: "url" returns storage URL, "base64" returns encoded
        image
      operationId: generate_thumbnail_api_v1_thumbnails_generate_post
      parameters:
        - name: X-API-Key
          in: header
          required: false
          schema:
            type: string
            title: X-Api-Key
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_generate_thumbnail_api_v1_thumbnails_generate_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ThumbnailResponse'
        '202':
          description: Async job created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobCreatedResponse'
        '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'
        '415':
          description: Unsupported file type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    Body_generate_thumbnail_api_v1_thumbnails_generate_post:
      properties:
        file:
          anyOf:
            - type: string
              contentMediaType: application/octet-stream
            - type: 'null'
          title: File
          description: File to generate thumbnail from
        url:
          anyOf:
            - type: string
            - type: 'null'
          title: Url
          description: URL to fetch file from
        url_headers:
          anyOf:
            - type: string
            - type: 'null'
          title: Url Headers
          description: JSON-encoded headers for URL auth
        width:
          type: integer
          maximum: 2000
          minimum: 50
          title: Width
          description: Max thumbnail width
          default: 600
        height:
          type: integer
          maximum: 2000
          minimum: 50
          title: Height
          description: Max thumbnail height
          default: 400
        quality:
          type: integer
          maximum: 100
          minimum: 1
          title: Quality
          description: JPEG quality
          default: 95
        sync:
          type: boolean
          title: Sync
          description: Wait for result or return job ID
          default: true
        webhook_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Webhook Url
          description: Webhook URL for async completion
        response_type:
          type: string
          title: Response Type
          description: 'Response type: ''url'' or ''base64'''
          default: url
      type: object
      title: Body_generate_thumbnail_api_v1_thumbnails_generate_post
    ThumbnailResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        job_id:
          type: string
          title: Job Id
          description: Unique job identifier
        status:
          $ref: '#/components/schemas/JobStatus'
          default: completed
        thumbnail_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Thumbnail Url
          description: URL to the thumbnail image
        thumbnail_base64:
          anyOf:
            - type: string
            - type: 'null'
          title: Thumbnail Base64
          description: Base64-encoded thumbnail (if response_type='base64')
        metadata:
          $ref: '#/components/schemas/ThumbnailMetadata'
          description: Thumbnail metadata
      type: object
      required:
        - job_id
        - metadata
      title: ThumbnailResponse
      description: Response for a completed thumbnail generation.
      example:
        job_id: job_abc123
        metadata:
          created_at: '2024-01-15T10:30:00Z'
          file_category: pdf
          file_size: 102400
          file_type: pdf
          mime_type: application/pdf
          original_filename: document.pdf
          thumbnail_height: 400
          thumbnail_width: 600
        status: completed
        success: true
        thumbnail_url: https://storage.example.com/thumbnails/thumb_abc123.jpg
    JobCreatedResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        job_id:
          type: string
          title: Job Id
          description: Unique job identifier for polling
        status:
          $ref: '#/components/schemas/JobStatus'
          default: pending
        message:
          type: string
          title: Message
          description: Instructions for the client
          default: Job created. Poll /api/v1/thumbnails/jobs/{job_id} for status.
      type: object
      required:
        - job_id
      title: JobCreatedResponse
      description: Response when an async job is created.
      example:
        job_id: job_abc123
        message: Job created. Poll /api/v1/thumbnails/jobs/{job_id} for status.
        status: pending
        success: true
    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
    JobStatus:
      type: string
      enum:
        - pending
        - processing
        - completed
        - failed
      title: JobStatus
      description: Job processing status.
    ThumbnailMetadata:
      properties:
        original_filename:
          type: string
          title: Original Filename
          description: Original filename
        file_type:
          type: string
          title: File Type
          description: File extension (e.g., 'pdf', 'png')
        file_category:
          $ref: '#/components/schemas/FileCategory'
          description: File category
        file_size:
          type: integer
          title: File Size
          description: Original file size in bytes
        mime_type:
          type: string
          title: Mime Type
          description: MIME type of the original file
        thumbnail_width:
          type: integer
          title: Thumbnail Width
          description: Thumbnail width in pixels
        thumbnail_height:
          type: integer
          title: Thumbnail Height
          description: Thumbnail height in pixels
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the thumbnail was created
      type: object
      required:
        - original_filename
        - file_type
        - file_category
        - file_size
        - mime_type
        - thumbnail_width
        - thumbnail_height
        - created_at
      title: ThumbnailMetadata
      description: Metadata about the generated thumbnail.
    FileCategory:
      type: string
      enum:
        - image
        - video
        - pdf
        - document
        - spreadsheet
        - presentation
        - markdown
        - code
        - text
        - unsupported
      title: FileCategory
      description: Supported file categories for thumbnail generation.

````