General OCR

​Extract text from an image.

http status
error code
error parameters
description

200

-

-

Successful Response

400

image_not_support

error <array>

image convert error

422

-

-

field required

​Extract text from an image

POST https://apis.aigen.online/aiscript/general-ocr/v2

Request Body

Name
Type
Description

image *

String

Full-page image or multi-page PDF encoded in base64 UTF-8 format

{
  "status": "200",
  "request_id": "string",
  "error": [
    {
      "object": "error",
      "code": "string",
      "message": "string"
    }
  ],
  "data": [
    {
      "bboxes": [
        {
          "bbox": [
            [
              0,
              0
            ],
            [
              50,
              0
            ],
            [
              50,
              50
            ],
            [
              0,
              50
            ]
          ],
          "bbox_norm": [
            [
              0.1,
              1
            ],
            [
              0.2,
              0.3
            ],
            [
              0.5,
              0.5
            ],
            [
              0.5,
              0.5
            ]
          ],
          "char_pos_norm": [
            0.01,
            0.03,
            0.05
          ],
          "text": "548 9",
          "confidence": 0.99875
        }
      ],
      "text_page": "123 abc\n",
      "page": 1,
      "max_page": 5
    }
  ]
}
import requests

api = "https://apis.aigen.online/aiscript/general-ocr/v2"
headers = {"x-aigen-key": "<key>"}
data = {"image": "<base64_string>"}

res = requests.post(api, json=data, headers=headers)
print(res.json())

Last updated