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

# Convert to Markdown

> Convert a file or URL to markdown.

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

**URL Fetch**: Provide a `url` field. For websites (HTML), uses a headless browser
to render the page before converting — handles JS-heavy sites.

**Supported formats**: PDF, DOCX, PPTX, XLSX, CSV, HTML, images, audio,
code files, and any URL via headless browser rendering.



## OpenAPI

````yaml /openapi.json post /api/v1/markdown/convert
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/markdown/convert:
    post:
      tags:
        - markdown
      summary: Convert to Markdown
      description: >-
        Convert a file or URL to markdown.


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


        **URL Fetch**: Provide a `url` field. For websites (HTML), uses a
        headless browser

        to render the page before converting — handles JS-heavy sites.


        **Supported formats**: PDF, DOCX, PPTX, XLSX, CSV, HTML, images, audio,

        code files, and any URL via headless browser rendering.
      operationId: convert_to_markdown_api_v1_markdown_convert_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_convert_to_markdown_api_v1_markdown_convert_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MarkdownResponse'
        '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'
components:
  schemas:
    Body_convert_to_markdown_api_v1_markdown_convert_post:
      properties:
        file:
          anyOf:
            - type: string
              contentMediaType: application/octet-stream
            - type: 'null'
          title: File
          description: File to convert
        url:
          anyOf:
            - type: string
            - type: 'null'
          title: Url
          description: URL to convert
        url_headers:
          anyOf:
            - type: string
            - type: 'null'
          title: Url Headers
          description: JSON-encoded headers for URL auth
        use_llm:
          type: boolean
          title: Use Llm
          description: Use LLM for image descriptions (costs tokens)
          default: false
      type: object
      title: Body_convert_to_markdown_api_v1_markdown_convert_post
    MarkdownResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: true
        markdown:
          type: string
          title: Markdown
          description: Converted markdown content
        filename:
          type: string
          title: Filename
          description: Original filename or URL
        content_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Type
          description: Detected MIME type
        content_length:
          type: integer
          title: Content Length
          description: Length of the markdown output in characters
      type: object
      required:
        - markdown
        - filename
        - content_length
      title: MarkdownResponse
      description: Response for markdown conversion.
      example:
        content_length: 1234
        content_type: application/pdf
        filename: document.pdf
        markdown: |-
          # Document Title

          This is the content...
        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
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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

````