Skip to main content
POST
/
v3
/
ocr
Extract text (OCR)
curl --request POST \
  --url https://api.opper.ai/v3/ocr \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "document": {
    "type": "<string>",
    "content": "<string>",
    "document_name": "<string>",
    "document_url": "<string>",
    "file_id": "<string>",
    "image_url": "<string>"
  },
  "model": "<string>"
}
'
import requests

url = "https://api.opper.ai/v3/ocr"

payload = {
"document": {
"type": "<string>",
"content": "<string>",
"document_name": "<string>",
"document_url": "<string>",
"file_id": "<string>",
"image_url": "<string>"
},
"model": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
document: {
type: '<string>',
content: '<string>',
document_name: '<string>',
document_url: '<string>',
file_id: '<string>',
image_url: '<string>'
},
model: '<string>'
})
};

fetch('https://api.opper.ai/v3/ocr', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
{
  "id": "<string>",
  "model": "<string>",
  "pages": [
    {
      "index": 123,
      "markdown": "<string>",
      "blocks": [
        {
          "bottom_right_x": 123,
          "bottom_right_y": 123,
          "top_left_x": 123,
          "top_left_y": 123,
          "type": "<string>",
          "content": "<string>"
        }
      ],
      "confidence_scores": {},
      "dimensions": {},
      "elements": [
        {}
      ],
      "images": [
        {}
      ]
    }
  ],
  "usage": {
    "cost": 123,
    "pages_processed": 123
  }
}
{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}
{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}
See the OCR guide for runnable examples, document sources (URL / base64 / file_id), and language options.

Authorizations

Authorization
string
header
required

API key authentication. Pass your API key as a Bearer token.

Body

application/json
document
object
required
model
string
required
image_limit
integer
image_min_size
integer
include_image_base64
boolean
pages
integer[]
parameters
object

Response

Successful response

id
string
required
model
string
required
pages
object[]
required
usage
object
required