Skip to content
  • There are no suggestions because the search field is empty.

Document AI API Reference

When given the PDF document and image input, the models return a response with extracted text.

Create an OCR

Extracts document information for the given document and image input.

Request

POST https://api.core42.ai/v1/ocr

Request Parameters

 

Parameter

Required

Type

Description

model

Yes

string

Model ID to use for extracting document information. Supported model is mistral-document-ai-2505.

type

False

string

The link type. The type value can be “document_url” or “image_url”.

document_url

Yes

string

The URL of the document in base64 format.

image_url

Yes

string

The URL of the image in base64 format.

bbox_annotation_format

 

False

null

Specify the format that the model must output. By default, it will use \{ "type": "text" \}. Setting to \{ "type": "json_object" \} enables JSON mode, ensuring the message the model generates is in JSON format. When using JSON mode, you MUST also instruct the model to produce JSON itself via a system or user message.

Setting to \{ "type": "json_schema" \} enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide.

Sample Format:

   "bbox_annotation_format": {        "type": "json_schema",        "json_schema": {            "schema": {                "properties": {                    "document_type": {"title": "Document_Type", "type": "string"},                    "short_description": {"title": "Short_Description", "type": "string"},                    "summary": {"title": "Summary",  "type": "string"}                },                "required": ["document_type", "short_description", "summary"],                "title": "bboxAnnotation",                "type": "object",                "additionalProperties": false            },            "name": "bbox_annotation",            "strict": true        }    },

document_annotation_format

False

null

Specify the format that the model must output. By default, it will use \{ "type": "text" \}. Setting to \{ "type": "json_object" \} enables JSON mode, ensuring the message the model generates is in JSON format. When using JSON mode, you MUST also instruct the model to produce JSON itself via a system or user message.

Setting to \{ "type": "json_schema" \} enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide.

Sample Format:
"document_annotation_format": {        "type": "json_schema",        "json_schema": {            "schema": {                "properties": {                    "language": {"title": "language", "type": "string"},                    "chapter_titles": {"title": "chapter_titles", "type": "string"},                    "urls": {"title": "urls",  "type": "string"}                },                "required": ["language", "chapter_titles", "urls"],                "title": "DOCAnnotation",                "type": "object",                "additionalProperties": false            },            "name": "document_annotation",            "strict": true        }    },

document_type

Yes

string

The type of the document.

short_description

Yes

string

Details of the image in English.

summary

Yes

string

Summary of the document.

language

Yes

string

Language in which the document is written.

chapter_titles

Yes

string

Document title or chapter titles of the document.

urls

Yes

string

Document URL or image URL.

include_image_base64

False

boolean, null

Includes image URLs in the response.

 

Document AI Usage Example

The following is an example showing the request and response sample format for using the OCR technology with the Document AI model.

For Images

Sample Request Format (Azure OpenAI)

 curl --location 'https://api.core42.ai/openai/deployments/mistral-document-ai-2505/ocr' 
--header 'Content-Type: application/json' 
--header "api-key: {API_KEY}" 
--data '{
      "document": {
       "type": "image_url",
       "image_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAgVBMVEX///8AAADn5+e9vb3s7OxLS0ve3t7t7e36+vrx8fH39/fFxcX8/Py2trY8PDzz8/Onp6ewsLBDQ0PR0dFXV1d7e3sYGBhHR0eenp6Pj483Nzd1dXUpKSna2tptbW3U1NQeHh6BgYENDQ1lZWWWlpYxMTEiIiJRUVFdXV2IiIihoaHp8VU7AAAHpklEQVR4nO2deXvbIAzGc9+Jj9xHnSZNtnTf/wMue2IjObU5bIIg4/1vHbX5FSyEENCYt95bx0ar8d7qeELn5Qndlyd0X57QfXlC9+UJ3ZcndF+e0H15QvflCd2XJ3RfntB9ecICDebRNll0zWuRbKP54NWEvcusSavZpfc6wiCKifEeiqPgJYSj8ECNxnQIR/oJx9TdM6/ZWDPhZEmN9EPLiU7C1o6ap0A7qarLEc5zTz7Hp3DaNq9peIrPuZrMdRGO0UNX+/FQ4rmvUjDer1BtJD5GGULUgp+bjoZq1lNn86nSihKELXjeibL5QMEJqiSsvphwwozMSqbbm9GcddWdyKKKCdkwsbajAR8arrNqLQUlhYTMyiyUfd6XarKQtDYiwkHmyaztArwjZq0449dMRBhm36BNXfShYfYthtxiAsIgc7btMTKgbBQ7cL1wAWGUDRN666ZJ2aAR8QoJCNP54KfCfMyggnToj3mF+IS99I+00Vw1Xdqk9ePN+vmEl9TM9HVXTZM6qbG58MpwCdOhYq+7Ztq0TwcMThEu4UBuTCV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1I5SYqG8FhOIJJykhQN4ak6oXKSFAnh8Fc5gFCqiQskhChaH7eGfbECvJtGMXGBhBCCiLKnL+EPVzFJioKwgqMJmW/KB8NREKLNMdKBCVgtVU1cICAcoP1N0oYRBXUU/RoCQhRbOssPbjeEqGRrCAhhN4VKBgL6u6jZGvOEuL8prOxO8N49lTmUeUI021sp/Fpu855K4oJxQtwWStFBPMaoJEkZJ8Tfk1rUBR+JXrIYx3mhOUJkEzmHUxUJbxNWsDWmCbGdUZwlBOhXD/K2xjQhagjlowix+y0fGzZNiDqpcuovdr/lw4qGCYMrVFLBWqRCcxL5b9gwIWxwqpKCj+xwLL0J2jBhB1YDK2zZGkAPkPe+TX+HLAO/UmYzBCHlU6SMjxZZI1ZaNp5kq6oKXdz4iP/xcE0q5v/0HjGsm0JI0bznPQqTWxJWPfIiuHzd9lWmo9S7ZF8oT+gJPSG9PKEn9IT08oSe0BPSyxN6Qk9IL0/oCd+e8P3vmXn/u4Le/76n97+zK7t3zb47SDPVvXfNnbvzOKtx//n9h+wOS/rrxovVr32H5fvfQ5odgmT5XbJrXiEB4fvfBzx6+zudrb6XO8v8qHUvN7pbXccp+DrF0t9n/EVxESEcjbCwC3HAEowE/oiQEPLN1jZ11CHbwCBKLxMTTljm58oeczNn2Vc7UdcSE+KUypMdzTg8QZWE1ZcgxKcCfG7oLyHvb9BRE+JuJUOID2JprvZjyoYcjvc4rV9i1iNFiFvxrnN8Cqdt85qGp/icq8m8ITbwcoSN1q5pn3ZSVZckbEyW4jca1lJugJYlvH+M1fcvv0Iz2cCDPGFjFB7ELzakQyidv6hAeGeMYvHLDSiOFOarSoR39S7UnXV2UTuWQJXwrsk82iaLrnktkm00V05drUDomDyh+/KE7ssTui9P6L48ofvyhO7LE7ovT+i+PKH78oTuyxO6L0/ovv4HwmO/887qf/wFbsRliVGeceYAAAAASUVORK5CYII="
      }
    }' -v 

Sample Request Format (OpenAI)

curl --location 'https://api.core42.ai/v1/ocr'
--header 'Content-Type: application/json' 
--header "api-key: {API_KEY}" 
--data '{
      "model": "mistral-document-ai-2505",
      "document": {
       "type": "image_url",
       "image_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAgVBMVEX///8AAADn5+e9vb3s7OxLS0ve3t7t7e36+vrx8fH39/fFxcX8/Py2trY8PDzz8/Onp6ewsLBDQ0PR0dFXV1d7e3sYGBhHR0eenp6Pj483Nzd1dXUpKSna2tptbW3U1NQeHh6BgYENDQ1lZWWWlpYxMTEiIiJRUVFdXV2IiIihoaHp8VU7AAAHpklEQVR4nO2deXvbIAzGc9+Jj9xHnSZNtnTf/wMue2IjObU5bIIg4/1vHbX5FSyEENCYt95bx0ar8d7qeELn5Qndlyd0X57QfXlC9+UJ3ZcndF+e0H15QvflCd2XJ3RfntB9ecICDebRNll0zWuRbKP54NWEvcusSavZpfc6wiCKifEeiqPgJYSj8ECNxnQIR/oJx9TdM6/ZWDPhZEmN9EPLiU7C1o6ap0A7qarLEc5zTz7Hp3DaNq9peIrPuZrMdRGO0UNX+/FQ4rmvUjDer1BtJD5GGULUgp+bjoZq1lNn86nSihKELXjeibL5QMEJqiSsvphwwozMSqbbm9GcddWdyKKKCdkwsbajAR8arrNqLQUlhYTMyiyUfd6XarKQtDYiwkHmyaztArwjZq0449dMRBhm36BNXfShYfYthtxiAsIgc7btMTKgbBQ7cL1wAWGUDRN666ZJ2aAR8QoJCNP54KfCfMyggnToj3mF+IS99I+00Vw1Xdqk9ePN+vmEl9TM9HVXTZM6qbG58MpwCdOhYq+7Ztq0TwcMThEu4UBuTCVU5o9whkQuYWqOz3bamX8anoWDGZcwkjBVxIqF4wWXcGvzYPhQOiRuy0twCRMZr4hWqVeZlJfgEqbu+1R/xbRp+qjiorwEl7D7+PW2/oppU/tRxW55CU/oCanlCT2hJ6SXJ/SEnpBe9hEGvZ7W2LJlhB/Lx5T8S19YxC7CNHL3T4l0sohAVhHmsjm6mhBtIgybOWmKUFpE2FnlCTWFKC0i/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8Tfk1rUBR+JXrIYx3mhOUJkEzmHUxUJbxNWsDWmCbGdUZwlBOhXD/K2xjQhagjlowix+y0fGzZNiDqpcuovdr/lw4qGCYMrVFLBWqRCcxL5b9gwIWxwqpKCj+xwLL0J2jBhB1YDK2zZGkAPkPe+TX+HLAO/UmYzBCHlU6SMjxZZI1ZaNp5kq6oKXdz4iP/xcE0q5v/0HjGsm0JI0bznPQqTWxJWPfIiuHzd9lWmo9S7ZF8oT+gJPSG9PKEn9IT08oSe0BPSyxN6Qk9IL0/oCd+e8P3vmXn/u4Le/76n97+zK7t3zb47SDPVvXfNnbvzOKtx//n9h+wOS/rrxovVr32H5fvfQ5odgmT5XbJrXiEB4fvfBzx6+zudrb6XO8v8qHUvN7pbXccp+DrF0t9n/EVxESEcjbCwC3HAEowE/oiQEPLN1jZ11CHbwCBKLxMTTljm58oeczNn2Vc7UdcSE+KUypMdzTg8QZWE1ZcgxKcCfG7oLyHvb9BRE+JuJUOID2JprvZjyoYcjvc4rV9i1iNFiFvxrnN8Cqdt85qGp/icq8m8ITbwcoSN1q5pn3ZSVZckbEyW4jca1lJugJYlvH+M1fcvv0Iz2cCDPGFjFB7ELzakQyidv6hAeGeMYvHLDSiOFOarSoR39S7UnXV2UTuWQJXwrsk82iaLrnktkm00V05drUDomDyh+/KE7ssTui9P6L48ofvyhO7LE7ovT+i+PKH78oTuyxO6L0/ovv4HwmO/887qf/wFbsRliVGeceYAAAAASUVORK5CYII="
      }
    }'

Sample Response Format

{
   "content_filter_results" : null,
   "document_annotation" : null,
   "model" : "mistral-document-ai-2505",
   "pages" : [
      {
         "dimensions" : {
            "dpi" : 200,
            "height" : 225,
            "width" : 225
         },
         "images" : [],
         "index" : 0,
         "markdown" : "(a)"
      }
   ],
   "usage_info" : {
      "doc_size_bytes" : 2156,
      "pages_processed" : 1,
      "pages_processed_annotation" : 0
   }
}

For Document

Sample Request Format

curl -X POST "https://api.core42.ai/v1/ocr" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AZURE_API_KEY" \
  -d '{
     "model": "mistral-document-ai-2505",
     "document": {
      "type": "document_url",
      "document_url": "data:application/pdf;base64,<content_of_base64_string>"
     },
     "document_annotation_format": {
       "type": "json_schema",
       "json_schema": {
           "schema": {
               properties": {
                    "language": {"title": "language", "description": "What language?", "type": "string"},
                    "chapter_titles": {"title": "chapter_titles", "description": "Chapter Titles", "type": "string"},
                    "urls": {"title": "urls", "description": "URLs", "type": "string"}
                },
                "required": ["language", "chapter_titles", "urls"],
                "title": "DDOCAnnotation",
                "type": "object",
                "additionalProperties": false
            },
            "name": "document_annotation",
           "strict": true
       }
     },
     "include_image_base64": true
   }'

Sample Response Format

{
    "pages": [
        {
            "index": 0,
            "images": [],
            "markdown": "This is a sample one-page PDF created using Python and ReportLab. It demonstrates how to generate a simple document with text content. You can modify this text to include any message or paragraph you want.",
            "dimensions": {
                "dpi": 200,
                "height": 2200,
                "width": 1700
            }
        }
    ],
    "model": "mistral-document-ai-2505",
    "document_annotation": "{\n  \"language\": \"English\",\n  \"chapter_titles\": \"Sample One-Page PDF\",\n  \"urls\": \"https://example.com/sample-pdf\"\n}",
    "usage_info": {
        "pages_processed": 0,
        "doc_size_bytes": 1618,
        "pages_processed_annotation": 1
    },
}