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

# Data extraction

> <p> Performs data extraction using LLM based on the specified data source, filter conditions, and JSON schema. Retrieves chunked data and uses the schema to extract and return the result as JSON via LLM. </p> <p> Required roles: All, App </p>




## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/qaip/openapi.documented.yml post /extract
openapi: 3.0.3
info:
  title: QAIP APIs
  version: 1.0.0
servers:
  - url: https://developer.qaip.com/api/v1
    description: API base path
security:
  - ApiKeyAuth: []
tags:
  - name: completions
    description: Generate completions
  - name: search
    description: Search content
  - name: extract
    description: Data extraction using LLM
  - name: tags
    description: List available tags
  - name: agent
    description: (Experimental) Agent operations
  - name: tag-source-groups
    description: Tag and source group associations
  - name: source-groups
    description: Source group (job) management and metadata
  - name: sources
    description: Sources management and metadata
  - name: local-file-groups
    description: Local file group management
  - name: secrets
    description: Secret management
  - name: google-drives
    description: Google Drive data source management
  - name: google-drive-settings
    description: Google Drive data source setting management
  - name: crawls
    description: Web crawl data source management
  - name: crawl-settings
    description: Web crawl setting management
  - name: githubs
    description: GitHub data source management
  - name: github-settings
    description: GitHub data source setting management
  - name: notions
    description: Notion data source management
  - name: notion-settings
    description: Notion data source setting management
  - name: authz-subject-attributes
    description: Authorization subject attribute management (admin only)
paths:
  /extract:
    post:
      tags:
        - extract
      summary: Data extraction
      description: >
        <p> Performs data extraction using LLM based on the specified data
        source, filter conditions, and JSON schema. Retrieves chunked data and
        uses the schema to extract and return the result as JSON via LLM. </p>
        <p> Required roles: All, App </p>
      operationId: extract
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExtractRequest'
      responses:
        '200':
          description: Successful extraction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Extract200Response'
        '400':
          description: Bad Request - The request was malformed or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from qaip import Qaip

            client = Qaip(
                api_key=os.environ.get("QAIP_API_KEY"),  # This is the default and can be omitted
            )
            response = client.extract(
                schema={},
            )
            print(response.created)
components:
  schemas:
    ExtractRequest:
      allOf:
        - $ref: '#/components/schemas/CommonFilter'
        - type: object
          required:
            - schema
          properties:
            limit:
              type: integer
              default: 10
              maximum: 100
              minimum: 1
            offset:
              type: integer
              default: 0
              minimum: 0
            authz_policy:
              type: string
              description: >
                (reserved for future use) Name of the registered authz policy to
                evaluate

                when retrieving content. Defaults to the reserved "default"
                policy when

                omitted. Ignored when authz is disabled.
              pattern: ^[a-z][a-z0-9_-]{0,63}$
              example: external-chatbot
            principal_id:
              type: string
              description: >
                Identifier of the end-user (principal) on whose behalf this
                request is made. Used to look up the principal's authz subject
                attributes for policy evaluation. When omitted, subject
                attributes are empty (most restrictive). Ignored when authz is
                disabled.
              maxLength: 256
              example: user-123
            schema:
              type: object
              description: |
                JSON Schema for the data to be extracted.
            prompt:
              type: string
              description: >
                Additional prompt for the LLM (optional, if not specified, a
                default prompt in Japanese will be used).
            use_related:
              type: boolean
              description: Whether to search for and use related content
            related_filter:
              allOf:
                - $ref: '#/components/schemas/CommonFilter'
                - type: object
                  properties:
                    limit:
                      type: integer
                      default: 10
                      maximum: 100
                      minimum: 1
                    offset:
                      type: integer
                      default: 0
                      minimum: 0
    Extract200Response:
      type: object
      required:
        - created
        - result
      properties:
        created:
          type: integer
          description: 抽出実行時刻（Unix timestamp）
        result:
          $ref: '#/components/schemas/ExtractResult'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              description: Human-readable error message
            type:
              type: string
              description: Machine-readable error code
    CommonFilter:
      type: object
      properties:
        tags:
          type: array
          items:
            type: string
        tag_ids:
          type: array
          items:
            type: string
        tag_filter_logic:
          $ref: '#/components/schemas/LogicalOperator'
        source_types:
          type: array
          items:
            $ref: '#/components/schemas/SourceType'
        file_types:
          type: array
          items:
            $ref: '#/components/schemas/FileType'
        date_from:
          type: integer
          description: Start date for content search (Unix timestamp in seconds)
          minimum: 1735639200
        date_to:
          type: integer
          description: End date for content search (Unix timestamp in seconds)
          minimum: 1735639200
        domains:
          type: array
          items:
            type: string
        metadata:
          $ref: '#/components/schemas/MetadataFilterGroup'
        source_metadata:
          $ref: '#/components/schemas/MetadataFilterGroup'
          description: >-
            Filter by individual source/file metadata from source_metadatas
            table
        chunk_metadata:
          $ref: '#/components/schemas/MetadataFilterGroup'
          description: Filter by chunk-level metadata from chunk_metadatas table
        use_postfilter:
          type: boolean
          default: false
          description: >
            Whether to bypass LanceDB prefilter and apply WHERE after the vector

            search (IVF_PQ) returns top-K. Significantly faster for broad
            filters

            that cover most of the table, but may return fewer than `limit`

            results when the hit rate is low.
    ExtractResult:
      type: object
      description: |
        Extraction result as a JSON object conforming to the provided schema.
    LogicalOperator:
      type: string
      enum:
        - AND
        - OR
      default: OR
      description: Logical operator for combining filter conditions
    SourceType:
      type: string
      description: The type of the source
      enum:
        - crawl
        - local_file
        - google_drive
        - github
        - notion
    FileType:
      type: string
      description: The type of the source file
      enum:
        - html
        - pdf
        - ppt
        - pptx
        - pptm
        - doc
        - docx
        - docm
        - xls
        - xlsx
        - xlsm
        - md
        - txt
        - jsonl
        - png
        - jpg
        - webp
        - heic
        - heif
        - wav
        - mp3
        - aiff
        - aac
        - m4a
        - ogg
        - flac
        - mp4
        - mpg
        - mov
        - avi
        - flv
        - webm
        - wmv
        - 3gp
        - notion_page
    MetadataFilterGroup:
      type: object
      description: >-
        (reserved for future use) Filter group with nested structure. Supports
        combining filters with AND/OR logic.
      properties:
        logic:
          $ref: '#/components/schemas/LogicalOperator'
        filters:
          type: array
          description: Filters within this group (combined using the logic operator)
          items:
            $ref: '#/components/schemas/MetadataFilter'
        groups:
          type: array
          description: Nested subgroups
          items:
            $ref: '#/components/schemas/MetadataFilterGroup'
          maxItems: 10
    MetadataFilter:
      type: object
      description: Metadata filter for filtering search results by key/value pairs
      required:
        - key
        - type
        - operator
      properties:
        key:
          type: string
          description: Metadata key
        val:
          description: >-
            Metadata value (string or number). This is optional since min/max
            can be used for range queries.
        type:
          type: string
          enum:
            - string
            - integer
            - float
            - date
            - datetime
          description: Data type of the metadata value
        operator:
          type: string
          enum:
            - eq
            - ne
            - gt
            - gte
            - lt
            - lte
            - between
          default: eq
          description: Comparison operator
        min:
          description: Minimum value for range queries (string or number)
        max:
          description: Maximum value for range queries (string or number)
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````