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

# OCR 服务

> 上传图片文件，使用指定工具类型进行 OCR（光学字符识别），支持手写体、文字等识别模式，见 [OCR 服务](/cn/guide/tools/zhipu-ocr)。点击 **Try it** 按钮可快速试用。



## OpenAPI

````yaml /openapi/openapi.json post /paas/v4/files/ocr
openapi: 3.0.1
info:
  title: ZHIPU AI API
  description: ZHIPU AI 接口提供强大的 AI 能力，包括聊天对话、工具调用和视频生成。
  license:
    name: ZHIPU AI 开发者协议和政策
    url: https://chat.z.ai/legal-agreement/terms-of-service
  version: 1.0.0
  contact:
    name: Z.AI 开发者
    url: https://chat.z.ai/legal-agreement/privacy-policy
    email: user_feedback@z.ai
servers:
  - url: https://open.bigmodel.cn/api/
    description: 开放平台服务
security:
  - bearerAuth: []
tags:
  - name: 模型 API
    description: Chat API
  - name: 工具 API
    description: Web Search API
  - name: Agent API
    description: Agent API
  - name: 文件 API
    description: File API
  - name: 知识库 API
    description: Knowledge API
  - name: 实时 API
    description: Realtime API
  - name: 批处理 API
    description: Batch API
  - name: 助理 API
    description: Assistant API
  - name: 智能体 API（旧）
    description: QingLiu Agent API
paths:
  /paas/v4/files/ocr:
    post:
      tags:
        - 工具 API
      summary: OCR 服务
      description: >-
        上传图片文件，使用指定工具类型进行 OCR（光学字符识别），支持手写体、文字等识别模式，见 [OCR
        服务](/cn/guide/tools/zhipu-ocr)。点击 **Try it** 按钮可快速试用。
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: 待识别的图片文件（如 JPG、PNG）
                tool_type:
                  type: string
                  enum:
                    - hand_write
                  description: OCR识别工具类型，可选 hand_write（手写体识别）
                language_type:
                  type: string
                  enum:
                    - CHN_ENG
                    - AUTO
                    - ENG
                    - JAP
                    - KOR
                    - FRE
                    - SPA
                    - POR
                    - GER
                    - ITA
                    - RUS
                    - DAN
                    - DUT
                    - MAL
                    - SWE
                    - IND
                    - POL
                    - ROM
                    - TUR
                    - GRE
                    - HUN
                    - THA
                    - VIE
                    - ARA
                    - HIN
                  description: 语言/识别模型类型，可选 CHN_ENG等
                probability:
                  type: boolean
                  example: true
                  default: false
                  description: 是否返回置信度（概率）信息。true 为返回
              required:
                - file
                - tool_type
        required: true
      responses:
        '200':
          description: 结果获取成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OCRResultResponse'
        default:
          description: 请求失败。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    OCRResultResponse:
      type: object
      properties:
        task_id:
          type: string
          description: OCR识别任务ID
          example: ce2641ced3e34e67b47f3b0feeb25aee
        message:
          type: string
          description: 结果状态描述
          example: 成功
        status:
          type: string
          enum:
            - succeeded
            - failed
          description: 任务处理状态
          example: succeeded
        words_result_num:
          type: integer
          description: 识别到的文本块/行数
          example: 4
        words_result:
          type: array
          description: 每个识别文本块/行的详细结果
          items:
            type: object
            properties:
              location:
                type: object
                properties:
                  left:
                    type: integer
                    example: 79
                  top:
                    type: integer
                    example: 122
                  width:
                    type: integer
                    example: 1483
                  height:
                    type: integer
                    example: 182
                required:
                  - left
                  - top
                  - width
                  - height
              words:
                type: string
                description: 识别出的文本内容
                example: 你好,世界!
              probability:
                type: object
                description: 置信度信息
                properties:
                  average:
                    type: number
                    example: 0.7320847511
                  variance:
                    type: number
                    example: 0.08768635988
                  min:
                    type: number
                    example: 0.3193874359
                required:
                  - average
                  - variance
                  - min
            required:
              - location
              - words
              - probability
      required:
        - task_id
        - message
        - status
        - words_result_num
    Error:
      type: object
      properties:
        error:
          required:
            - code
            - message
          type: object
          properties:
            code:
              type: string
            message:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        标准的 HTTP Bearer 认证方式，在 [API
        Keys](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) 页面获取密钥。

````