Skip to main content

OCR

POST 

/v1/tools/ocr

Recognize the text in a PDF, Word or PowerPoint document or in an image, and return the result page by page. The file is not stored in the Files API. See the OCR guide for the limits, errors and billing.

Request​

Body

required

    file binaryrequired

    The file to recognize, sent with a file name. See the OCR guide for the supported formats and limits.

    purpose stringrequired

    Possible values: text_recognition, rich_layout_recognition

    text_recognition extracts text directly from Word and PowerPoint files without images and recognizes other files page by page. rich_layout_recognition recognizes every file page by page. See the OCR guide for the output.

Responses​

OK, returns the recognition result of every page.

Schema

    id stringrequired

    The recognition ID, of the form ocr-....

    object stringrequired

    Possible values: ocr.result

    The object type, which is always ocr.result.

    created integerrequired

    The Unix timestamp (in seconds) of when the recognition was created.

    purpose stringrequired

    Possible values: text_recognition, rich_layout_recognition

    The purpose of the request.

    page_count integerrequired

    The number of pages, equal to the length of pages.

    pages

    object[]

    required

    The recognition result of every page, in page order.

  • Array [

  • index integerrequired

    The page number, starting from 0.

    text stringrequired

    The raw model output for the page, without any cleanup.

    finish_reason stringrequired

    Possible values: stop, length

    stop when the page was recognized completely; length when the output reached the limit and the page text is incomplete.

  • ]

  • usage

    object

    required

    The token usage of all pages. For reference only; not used for billing.

    input_tokens integerrequired

    The OCR input tokens of all pages. For reference only; not used for billing.

    output_tokens integerrequired

    The OCR output tokens of all pages. For reference only; not used for billing.

    total_tokens integerrequired

    The sum of input_tokens and output_tokens.

Loading...