openapi: 3.0.3
info:
  title: 文字识别 VLM Beta API
  description: xParse 文字识别 VLM 模型
  version: 4.0.0.dev0
  contact:
    name: TextIn API Team
servers:
  - url: https://api.textin.com
    description: Production server
security:
  - AppIdAuth: []
    SecretCodeAuth: []
paths:
  /ai/service/v4/recognize/document:
    post:
      summary: Parse
      description: Parse image
      operationId: parse_ai_service_v4_recognize_document_post
      tags:
        - 文字识别VLM
      requestBody:
        description: |
          支持以下两种请求格式：

          1. Content-Type: application/octet-stream

             请求体为本地文件的二进制流，非 FormData 或其他格式

          2. Content-Type: text/plain

             请求体为文本，内容为在线文件的URL链接（支持http以及https协议）。

          支持的文件格式：图片（png, jpg, jpeg, bmp, tiff, webp）。
          单个文件大小不超过50M。
        required: true
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
            examples:
              file:
                summary: 本地文件二进制流
                description: 上传本地文件的二进制内容
          text/plain:
            schema:
              type: string
            examples:
              url:
                summary: 在线文件URL
                description: 提供在线文件的URL链接（http/https）
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentResponse'
components:
  securitySchemes:
    AppIdAuth:
      type: apiKey
      in: header
      name: x-ti-app-id
      description: >-
        请[登录Textin](https://www.textin.com/console/dashboard/setting)后前往
        "工作台-账号设置-开发者信息" 查看 x-ti-app-id
    SecretCodeAuth:
      type: apiKey
      in: header
      name: x-ti-secret-code
      description: >-
        请[登录Textin](https://www.textin.com/console/dashboard/setting)后前往
        "工作台-账号设置-开发者信息" 查看 x-ti-secret-code
  schemas:
    ChunkType:
      type: string
      title: ChunkType
      enum:
        - textchunk
        - table
        - image
        - stamp
        - qrcode_barcode
        - chart
        - card_doc_image
        - formula
        - algorithm_code_block
        - textchunk_text_title
        - textchunk_table_title
        - textchunk_image_title
        - header_footer
    ParseChunkResult:
      type: object
      title: ParseChunkResult
      required:
        - chunk_type
      properties:
        chunk_type:
          $ref: '#/components/schemas/ChunkType'
        position:
          type: array
          title: Position
          items:
            type: integer
        text:
          type: string
          title: Text
          default: ''
    VLMResult:
      type: object
      title: VLMResult
      required:
        - parse_chunk_results
      properties:
        image_angle:
          type: integer
          title: Image Angle
          default: 0
        image_angle_score:
          type: number
          title: Image Angle Score
          default: 0
        image_width:
          type: integer
          title: Image Width
          default: 0
        image_height:
          type: integer
          title: Image Height
          default: 0
        parse_chunk_results:
          type: array
          title: Parse Chunk Results
          items:
            $ref: '#/components/schemas/ParseChunkResult'
    DocumentResponse:
      type: object
      title: DocumentResponse
      required:
        - code
        - message
        - duration
        - result
        - version
      properties:
        code:
          type: integer
          title: Code
          default: 200
        message:
          type: string
          title: Message
          default: success
        duration:
          type: number
          title: Duration
          default: 1250.87
        result:
          $ref: '#/components/schemas/VLMResult'
        version:
          type: string
          title: Version
          default: 4.0.0.dev0
