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

# Extract API - Multi-mode page extraction

> Extract from a single web page in one call. Combine any modes: structured JSON ('json', $0.005), a markdown summary ('summary', $0.005), an answer to a question ('qa', $0.005), all page links ('links', $0.001), and a brand profile with logos/colors/socials ('brand', $0.002). Pricing is summed per selected mode; advanced proxy adds $0.004 once when a scrape runs. If the request fails before any AI cost is incurred (page fetch failure, empty content, brand fetch failure), you are fully refunded.



## OpenAPI

````yaml post /api/v2/extract
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/extract:
    post:
      tags:
        - Content Extraction
      summary: Extract API - Multi-mode page extraction
      description: >-
        Extract from a single web page in one call. Combine any modes:
        structured JSON ('json', $0.005), a markdown summary ('summary',
        $0.005), an answer to a question ('qa', $0.005), all page links
        ('links', $0.001), and a brand profile with logos/colors/socials
        ('brand', $0.002). Pricing is summed per selected mode; advanced proxy
        adds $0.004 once when a scrape runs. If the request fails before any AI
        cost is incurred (page fetch failure, empty content, brand fetch
        failure), you are fully refunded.
      operationId: extract
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExtractRequest'
      responses:
        '200':
          description: >-
            Extraction results. All result fields (structured_data, summary,
            answer, links, brand) are always present; modes you did not request
            are null.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          description: >-
            The page returned no extractable content (fully refunded), or the
            JSON output was truncated before completion.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerAuth: []
components:
  schemas:
    ExtractRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          description: >-
            The page URL to extract from. Must be http(s). PDF URLs are not
            supported — use /get_pdf_content instead.
          example: https://www.ycombinator.com/blog
        modes:
          type: array
          items:
            type: string
            enum:
              - json
              - summary
              - qa
              - links
              - brand
          default:
            - json
          description: >-
            Extraction modes to run in one call. Any combination; duplicates are
            ignored. Pricing is summed per mode: json/summary/qa $0.005 each,
            links $0.001, brand $0.002.
          example:
            - json
            - summary
        json_schema:
          description: >-
            Required when modes includes 'json'. Accepts a formal JSON schema,
            an example object (e.g. {"title": "string", "price": "number"}), or
            a plain-text description of the fields you want.
          oneOf:
            - type: string
            - type: object
        query:
          type: string
          description: >-
            The question to answer from the page — required when modes includes
            'qa'.
        instructions:
          type: string
          description: >-
            Optional extra guidance applied to all AI modes (json, summary, qa).
            E.g. 'dates in DD/MM/YYYY format'.
        response_language:
          type: string
          default: auto
          description: >-
            Output language for summary/qa ('auto' matches the user/page
            language). E.g. 'en', 'fr', 'es'.
        advanced_proxy:
          type: boolean
          default: false
          description: >-
            Use advanced proxy for sites with bot protection. Adds $0.004 once
            per request, only when a scrape runs (brand-only requests never
            scrape).
        main_content_only:
          type: boolean
          description: >-
            Omit this field to let the API pick the best default per selection:
            links-only requests scrape the full page (nav/footer links matter),
            AI modes use main content only.
    ExtractResponse:
      type: object
      description: >-
        All five result fields are always present; modes you did not request are
        null. The json mode result is returned as structured_data.
      properties:
        url:
          type: string
          description: Final URL after redirects.
        title:
          type: string
          nullable: true
          description: Page title.
        metadata:
          type: object
          nullable: true
          description: >-
            Page metadata (description, OpenGraph fields, language, ...) as
            found by the scraper.
        structured_data:
          type: object
          nullable: true
          description: Structured data matching your schema (when 'json' in modes).
        summary:
          type: string
          nullable: true
          description: Markdown summary of the page (when 'summary' in modes).
        answer:
          type: string
          nullable: true
          description: Markdown answer to your question (when 'qa' in modes).
        links:
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/ExtractLink'
          description: >-
            All links found on the page, deduplicated, max 500 (when 'links' in
            modes).
        brand:
          type: object
          nullable: true
          description: >-
            Brand profile: domain, title, description, colors, logos, backdrops,
            socials, industries, key links and pages (when 'brand' in modes).
        cost:
          type: number
          description: >-
            Total cost in USD — sum of the selected modes (+$0.004 advanced
            proxy when a scrape runs).
          example: 0.01
        response_time:
          type: string
          description: Total processing time in seconds.
          example: '3.42'
        statusCode:
          type: integer
          example: 200
    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
    ExtractLink:
      type: object
      properties:
        url:
          type: string
          description: Absolute URL of the link.
        text:
          type: string
          description: Anchor text of the link (may be empty).
        internal:
          type: boolean
          description: True when the link points to the same site (including subdomains).
  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>'''
    RateLimitError:
      description: Rate limit exceeded or insufficient credits
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            provider_rate_limit:
              value:
                detail:
                  error_type: provider_error
                  error_code: openai_rate_limit
                  message: Rate limit exceeded for openai. Please try again later
                  details:
                    provider: openai
    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
  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

````