OCR

Extract Text from Images with OCR

Changed on

Use specialized OCR vision models to extract and recognize text from images via the OpenAI-compatible chat completions API.

post/chat/completions

Request

Request body

modelstring required

The OCR-specialized vision model to use for text extraction.

max_tokensinteger

Maximum number of tokens to generate in the OCR response.

temperaturenumber

Sampling temperature for text extraction (lower = more deterministic).

top_pnumber

Nucleus sampling parameter for OCR output.

streamboolean

Whether to stream OCR output incrementally.

Example request

{
  "model": "Hunyuan/Hunyuan-OCR-1B",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Extract all text from this image and preserve the layout structure.",
          "image_url": {
            "url": "https://example.com/document.png"
          }
        }
      ]
    }
  ]
}

Response

OCR text extraction completed successfully

idstring
objectstring
createdinteger
modelstring

Example response

{
  "id": "chatcmpl-ocr-123456",
  "object": "chat.completion",
  "created": 1710000000,
  "model": "Hunyuan/Hunyuan-OCR-1B",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Header: Important Document\n\nSection 1: Introduction\nThis document contains important information...\n\nSection 2: Details\nKey points and data extracted from the image..."
      },
      "finish_reason": "stop"
    }
  ]
}

Changes

    • breaking

      the response's property type changed from string to object for status

    • breaking

      the response's property type changed from string to object for status

    • breaking

      the response's property type changed from string to object for status

    • breaking

      the response's property type changed from string to object for status

    • breaking

      the response's property type changed from string to object for status

    • breaking

      the response's property type changed from string to object for status

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • warning

      removed the optional property from the response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      removed the non-success response with the status

    • info

      removed the non-success response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      added the optional property / to the response with the status

    • info

      the response property became required for the status

    • info

      the response property became required for the status

    • info

      the response property became required for the status

    • info

      the response property became required for the status

    • info

      the response property became required for the status

    • info

      the response property became required for the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      added the required property / to the response with the status

    • info

      api operation id createVisionCompletion removed and replaced with createOCRCompletion

    • info

      api tag OCR added

    • info

      api tag Vision removed

    • info

      the request property default value changed from 16384 to 8192

    • info

      the request property default value changed from true to false