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

# PDF Content API - Extract text from PDFs

> Extract text content from PDF documents. 15-second timeout with proper 504 handling.



## OpenAPI

````yaml post /api/v2/get_pdf_content
openapi: 3.0.0
info:
  title: LLMLayer API
  version: 2.0.0
  description: >-
    The Web API for AI Agents - Search, scrape, extract content, crawl websites,
    and generate AI-powered answers with multiple LLMs
servers:
  - url: https://api.llmlayer.dev
security: []
tags:
  - name: Answer API
    description: >-
      Web-enhanced AI responses combining search with multiple LLM models.
      Supports streaming, custom prompts, and structured JSON output.
  - name: Web Search
    description: >-
      Direct web search across multiple content types (general, news, shopping,
      videos, images, scholar) without AI processing.
  - name: Content Extraction
    description: >-
      Extract content from websites, PDFs, and YouTube videos in multiple
      formats.
  - name: Web Crawling
    description: >-
      Map websites and crawl multiple pages with depth control. Supports
      streaming with markdown output.
paths:
  /api/v2/get_pdf_content:
    post:
      tags:
        - Content Extraction
      summary: PDF Content API - Extract text from PDFs
      description: >-
        Extract text content from PDF documents. 15-second timeout with proper
        504 handling.
      operationId: getPdfContent
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PDFRequest'
      responses:
        '200':
          description: Extracted PDF content with page count
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PDFResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '504':
          $ref: '#/components/responses/TimeoutError'
      security:
        - BearerAuth: []
components:
  schemas:
    PDFRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: Direct URL to PDF document
          example: >-
            https://www.ycombinator.com/blog/content/files/2024/06/RemedyFest-Final-Report.pdf
    PDFResponse:
      type: object
      required:
        - text
        - pages
        - url
        - statusCode
      properties:
        text:
          type: string
          description: Extracted text content from all pages
        pages:
          type: integer
          description: Number of pages in the PDF
        url:
          type: string
          description: The PDF URL
        statusCode:
          type: integer
          description: HTTP status code (200 for success)
        cost:
          type: number
          description: Cost in USD ($0.002 per PDF extraction)
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: object
          required:
            - error_type
            - error_code
            - message
          properties:
            error_type:
              type: string
              enum:
                - validation_error
                - authentication_error
                - provider_error
                - rate_limit
                - internal_error
                - scraping_error
                - search_error
                - map_error
              description: Category of error
            error_code:
              type: string
              description: Specific error code for programmatic handling
              example: missing_query
            message:
              type: string
              description: Human-readable error message
            details:
              type: object
              additionalProperties: true
              nullable: true
              description: Additional error context and debugging information
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missing_query:
              value:
                detail:
                  error_type: validation_error
                  error_code: missing_query
                  message: Query parameter cannot be empty
            missing_json_schema:
              value:
                detail:
                  error_type: validation_error
                  error_code: missing_json_schema
                  message: JSON schema is required for JSON response type
            invalid_max_pages:
              value:
                detail:
                  error_type: validation_error
                  error_code: invalid_max_pages
                  message: max_pages must be between 1 and 100
    Unauthorized:
      description: Authentication error - missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail:
              error_type: authentication_error
              error_code: missing_llmlayer_api_key
              message: 'Provide LLMLayer API key via ''Authorization: Bearer <token>'''
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            unexpected_error:
              value:
                detail:
                  error_type: internal_error
                  error_code: unexpected_error
                  message: An unexpected error occurred. Please try again later
            scraping_error:
              value:
                detail:
                  error_type: scraping_error
                  error_code: url_scrape_failed
                  message: Failed to scrape content from the provided URL
                  details:
                    url: https://www.ycombinator.com
                    error: Connection timeout
    TimeoutError:
      description: Operation timeout (504 Gateway Timeout)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail:
              error_type: scraping_error
              error_code: pdf_scrape_timeout
              message: PDF scraping exceeded the 15-second limit
              details:
                url: >-
                  https://www.ycombinator.com/blog/content/files/2024/06/RemedyFest-Final-Report.pdf
                timeout_seconds: 15
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token authentication using your LLMLayer API key. Include in
        Authorization header as: Bearer YOUR_LLMLAYER_API_KEY

````