Image

Universal OCR Text Recognition

0calls
4 credits / call

Whether you need to implement automated receipt entry, or highlight text coordinates on images in web frontend, this high-precision OCR endpoint can provide you with powerful basic capabilities.

Overview

Important

If you only care about what's written on the image (such as screenshot text extraction or content security review), it is strongly recommended to setneed_location to false. This will significantly reduce the size of returned JSON data, improving network transmission and system parsing efficiency.

In addition to regular image-to-text conversion, this endpoint has some practical designs for actual development scenarios:

  • Frontend Text Highlighting and Structured Analysis: By default returns rectangular coordinates and four vertex coordinates for each paragraph of text. This is very suitable for using Canvas to draw boxes and highlight on the original image, or extracting key-value pair information from receipts based on relative positions on the backend.
  • Anti-Distortion in Complex Shooting Environments: For rotation or tilt caused by mobile phone shooting, you can enable enable_cls=true. The server will automatically perform direction pre-correction before recognition, significantly improving recognition accuracy.
  • Flexible Input and Request Requirements: The endpoint supports three input methods: file, url or image_base64. Please ensure the request format is multipart/form-data, and the image link is directly accessible from the public internet.

Request body

Form data containing image to be recognized and optional configurations. Regardless of input method, request body must use multipart/form-data format. Please choose one of file, url or image_base64 as input source.

file
fileoptional

Image file to be recognized. Supports common formats such as JPG, JPEG, PNG, BMP, GIF, WebP, etc., maximum size not exceeding 10MB. Do not submit together with url or image_base64.

url
stringoptional

Publicly accessible image address. Do not submit together with file or image_base64.

image_base64
stringoptional

Base64 string of the image. Can pass complete Data URI or only pure Base64 content. Do not submit together with file or url.

image_name
stringoptional

Custom image filename. Recommended to pass together when passing link or pure Base64, to facilitate retaining or inferring extension.

need_location
stringoptional

Whether to return text coordinate information. Please pass true or false, defaults to true when not passed.

return_markdown
stringoptional

Whether to additionally return organized Markdown text. Please pass true or false, defaults to false when not passed.

enable_cls
stringoptional

Whether to enable additional text direction correction. Please pass true or false, defaults to false when not passed.

Response

200 / OK

Recognition successful, returns unified OCR result object. Includes coordinate information by default; when need_location=false, coordinate-related fields will be omitted.

JSON

400 / Bad Request

Request parameters are incorrect, such as not providing image source, submitting multiple image sources, or invalid boolean parameters and Base64 format.

Format 1Missing Image Source
JSON
Format 2Input Source Conflict
JSON
Format 3Base64 Format Error
JSON

413 /

Image size exceeds current limit.

JSON

415 /

Uploaded content is not a recognizable common image format.

JSON

502 / Bad Gateway

Recognition processing failed, please try again later.

JSON

503 / Service Unavailable

Text recognition service is temporarily unavailable, please try again later.

JSON