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

# Generate extraction field prompts

> Generate field names, field types, field prompts, and other configuration references from a sample document or prompt. When you pass the app_id of a high-speed custom extraction application, the high-speed auto-configuration service returns a configuration preview such as common_rule, field_rule, and table_rule. This endpoint does not save a configuration version or automatically populate the Web application. High-speed applications must provide file_url or file_base64. prompt is only used as an auxiliary instruction.



## OpenAPI

````yaml /en/api-reference/adp-api.yaml post /open/agentic_doc_processor/{tenant_name}/v1/app-manage/ai-recommend
openapi: 3.1.0
info:
  title: ADP API
  version: 1.0.0
  description: >-
    Laiye ADP OpenAPI reference for document extraction, document recognition,
    application management, credit usage, workflow runs, and workflow file
    management.
  license:
    name: MIT
    identifier: MIT
servers:
  - url: https://adp-global.laiye.com
    description: ADP global production endpoint
security: []
tags:
  - name: Document extraction
    description: Extract structured fields from uploaded documents.
  - name: Document recognition
    description: Recognize text, layout blocks, and positions from uploaded documents.
  - name: Application management
    description: >-
      Create, update, delete, and query extraction applications and
      configurations.
  - name: Account
    description: Query credit usage.
  - name: Workflow
    description: Run workflow applications and query run results.
  - name: Workflow files
    description: Upload and manage files used by workflow applications.
paths:
  /open/agentic_doc_processor/{tenant_name}/v1/app-manage/ai-recommend:
    post:
      tags:
        - Application management
      summary: Generate extraction field prompts
      description: >-
        Generate field names, field types, field prompts, and other
        configuration references from a sample document or prompt. When you pass
        the app_id of a high-speed custom extraction application, the high-speed
        auto-configuration service returns a configuration preview such as
        common_rule, field_rule, and table_rule. This endpoint does not save a
        configuration version or automatically populate the Web application.
        High-speed applications must provide file_url or file_base64. prompt is
        only used as an auxiliary instruction.
      operationId: recommendExtractionFields
      parameters:
        - $ref: '#/components/parameters/TenantName'
      requestBody:
        $ref: '#/components/requestBodies/AiRecommendRequest'
      responses:
        '200':
          $ref: '#/components/responses/AiRecommendResponse'
        '422':
          $ref: '#/components/responses/ValidationError'
      security:
        - ApiKeyAuth: []
components:
  parameters:
    TenantName:
      name: tenant_name
      in: path
      required: true
      description: 'Tenant name. Default: laiye.'
      schema:
        type: string
        default: laiye
  requestBodies:
    AiRecommendRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AiRecommendRequest'
          examples:
            standardCustomExtractionApp:
              summary: >-
                Generate field prompts for a standard custom extraction
                application
              value:
                app_id: app_1406
                file_url: >-
                  https://adp.laiye.com/web/agentic_doc_processor/laiye/file/2003c711818811f1a36200163e358400
                prompt: >-
                  Extract the invoice number, invoice date, and total amount
                  from the invoice.
            highSpeedCustomExtractionApp:
              summary: Generate a high-speed custom extraction configuration preview
              value:
                app_id: app_1425
                file_url: >-
                  https://adp.laiye.com/web/agentic_doc_processor/laiye/file/2003c711818811f1a36200163e358400
                prompt: >-
                  Generate field configuration based on the document layout. Use
                  English snake_case field keys.
  responses:
    AiRecommendResponse:
      description: >-
        Field configuration generation result. High-speed applications return a
        configuration preview and do not save a configuration version.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AiRecommendResponse'
          examples:
            standardCustomExtractionApp:
              summary: Recommended fields for a standard custom extraction application
              value:
                code: success
                message: ''
                tips: null
                data:
                  app_id: app_1406
                  app_name: ''
                  extract_fields:
                    - field_name: Invoice number
                      field_type: string
                      field_prompt: Extract the unique identifier of the tax invoice.
                    - field_name: Invoice date
                      field_type: date
                      field_prompt: Extract the invoice issue date.
            highSpeedCustomExtractionApp:
              summary: Generated high-speed custom extraction configuration preview
              value:
                code: success
                message: ''
                tips: null
                data:
                  app_id: app_1425
                  app_name: High-speed invoice extraction app
                  ai_function: 1425
                  extract_fields:
                    - field_key: invoice_number
                      field_name: Invoice number
                      field_type: string
                      field_prompt: Unique identifier of the tax invoice.
                      field_description: Unique identifier of the tax invoice.
                    - field_key: invoice_date
                      field_name: Invoice date
                      field_type: date
                      field_prompt: Invoice issue date.
                      field_description: Invoice issue date.
                  prompt_rule: Extract only fields that clearly appear in the document.
                  common_rule: Extract only fields that clearly appear in the document.
                  field_rule:
                    - field_key: invoice_number
                      field_name: Invoice number
                      field_type: string
                      field_description: Unique identifier of the tax invoice.
                    - field_key: invoice_date
                      field_name: Invoice date
                      field_type: date
                      field_description: Invoice issue date.
                  table_rule:
                    - field_key: line_items
                      field_name: Line items
                      field_type: table
                      field_description: Invoice line item table.
                      field_parent_id: ''
                    - field_key: item_name
                      field_name: Item name
                      field_type: string
                      field_description: Product or service name in the line item.
                      field_parent_id: line_items
                    - field_key: item_amount
                      field_name: Amount
                      field_type: string
                      field_description: Line item amount.
                      field_parent_id: line_items
                  page_count: 2
                  document_type: invoice
    ValidationError:
      description: Validation error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SimpleResponse'
  schemas:
    AiRecommendRequest:
      type: object
      additionalProperties: false
      description: >-
        Field configuration generation request. The request body must provide
        file_url or file_base64. prompt can be used as an auxiliary generation
        instruction.
      properties:
        app_id:
          type: string
          description: >-
            Application ID. When you pass a high-speed custom extraction
            application, the response returns a high-speed auto-configuration
            preview.
        file_base64:
          type: string
          description: >-
            Base64-encoded file. Required for high-speed applications if
            file_url is not provided.
        file_url:
          type: string
          format: uri
          description: >-
            File URL. Required for high-speed applications if file_base64 is not
            provided.
        prompt:
          type: string
          description: >-
            User-provided generation instruction. Provide a file as well, and
            use prompt only as an auxiliary instruction.
        doc_type:
          type: string
          description: >-
            Document type. You can provide this for standard application
            recommendations. High-speed applications detect the document type
            automatically.
        doc_type_description:
          type: string
          description: >-
            Document type description. You can provide this for standard
            application recommendations.
      required:
        - app_id
      anyOf:
        - required:
            - file_base64
        - required:
            - file_url
    AiRecommendResponse:
      allOf:
        - $ref: '#/components/schemas/SimpleResponse'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/AiRecommendData'
    SimpleResponse:
      type: object
      properties:
        code:
          oneOf:
            - type: string
            - type: integer
          description: Business code. A successful response is usually success or 200.
        message:
          type: string
          description: Response message.
        tips:
          type:
            - string
            - 'null'
          description: Details. Defaults to null.
    AiRecommendData:
      type: object
      additionalProperties: true
      properties:
        app_id:
          type: string
          description: Application ID.
        app_name:
          type: string
          description: Application name.
        ai_function:
          type: integer
          enum:
            - 1406
            - 1425
          description: >-
            Application type. 1406 means standard custom extraction. 1425 means
            high-speed custom extraction.
        extract_fields:
          type: array
          description: >-
            Compatibility field list. Standard applications return recommended
            fields. High-speed applications currently return an ordinary field
            preview here. Use field_rule and table_rule for the full
            configuration.
          items:
            $ref: '#/components/schemas/AiRecommendFieldConfig'
        prompt_rule:
          type: string
          description: Overall rule for high-speed auto-configuration. Compatibility field.
        common_rule:
          type: string
          description: Overall rule for high-speed auto-configuration.
        field_rule:
          type: array
          description: >-
            Ordinary field configuration preview generated for high-speed
            applications. This field is not automatically saved to the
            application configuration.
          items:
            $ref: '#/components/schemas/AiRecommendGeneratedRuleField'
        table_rule:
          type: array
          description: >-
            Table field configuration preview generated for high-speed
            applications. This uses a flat structure. Records whose
            field_parent_id is empty are table parent fields. Records whose
            field_parent_id points to a parent field_key are table sub-fields.
          items:
            $ref: '#/components/schemas/AiRecommendGeneratedRuleField'
        page_count:
          type: integer
          description: Number of pages used for high-speed auto-configuration.
        document_type:
          type: string
          description: Document type detected automatically by the high-speed service.
    AiRecommendFieldConfig:
      type: object
      additionalProperties: true
      properties:
        field_key:
          type: string
          description: Unique field identifier. Returned for high-speed auto-configuration.
        field_name:
          type: string
          description: Field name.
        field_type:
          type: string
          enum:
            - string
            - date
            - table
          description: Field type.
        field_prompt:
          type:
            - string
            - 'null'
          description: Field prompt.
        field_description:
          type:
            - string
            - 'null'
          description: Field description.
        sub_fields:
          type: array
          description: >-
            Table sub-field list. Standard table fields may return this field.
            For high-speed table fields, use table_rule.
          items:
            $ref: '#/components/schemas/AiRecommendSubFieldConfig'
      required:
        - field_name
        - field_type
    AiRecommendGeneratedRuleField:
      type: object
      additionalProperties: true
      properties:
        field_key:
          type: string
          description: >-
            Unique field identifier. A table sub-field's field_parent_id
            references the table parent field's field_key.
        field_name:
          type: string
          description: Field name.
        field_type:
          type: string
          enum:
            - string
            - date
            - table
          description: Field type. table means a table parent field.
        field_description:
          type: string
          description: Field description.
        field_parent_id:
          type: string
          description: >-
            Parent field_key for a table sub-field. Empty means an ordinary
            field or a table parent field.
        config:
          type: object
          additionalProperties: true
          description: Field extension configuration.
        source:
          type: integer
          description: Field source.
        _field_key_source:
          type: string
          description: >-
            Original field key generated by the model. Returned only when the
            service keeps debug information.
    AiRecommendSubFieldConfig:
      type: object
      additionalProperties: true
      properties:
        field_key:
          type: string
          description: Unique sub-field identifier.
        field_name:
          type: string
          description: Sub-field name.
        field_type:
          type: string
          enum:
            - string
            - date
          description: Sub-field type.
        field_prompt:
          type:
            - string
            - 'null'
          description: Sub-field prompt.
        field_description:
          type:
            - string
            - 'null'
          description: Sub-field description.
      required:
        - field_name
        - field_type
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        Production OpenAPI Accessor access_key. You can find it in My API in the
        ADP platform. If the key is disabled, expired, or does not belong to the
        production environment, the API returns Accessor not found.

````