AI-API - Read the text printed in a picture (image_ocr)

AI API: Vectors, Images & LLM

Opensolr API Endpoint: image_ocr

Overview

The image_ocr endpoint reads the text printed in a picture — up to 5 pictures in one call — and answers the words it read. It is the other half of picture search: image_index and image_clip tell you what a picture shows; image_ocr tells you what is written on it.

That difference is the whole point for paperwork:

Picture What the words endpoints say What image_ocr reads
A petrol receipt receipt, paper, text, document PETROM STATION 1042, TOTAL 300.86 LEI, BON FISCAL 004417
A supplier invoice invoice, document, letter The company, the invoice number, the amount, the due date
A shelf label label, product label, price tag The product name and its article number
A screenshot screenshot, website, text Whatever it says
A business card business card, text The name, the company, the phone number

Index that text and a folder of receipts becomes searchable the way a customer actually remembers it: by the petrol station, by the total, by the invoice number. This is how Opensolr Photos makes a phone full of paperwork searchable, and the same endpoint is open to any account.

Reading runs on a dedicated set of Opensolr Solr servers — machines that do nothing else — never on the GPU box, so a bulk run does not queue behind the embedding and LLM work.


Endpoint URL

https://opensolr.com/solr_manager/api/image_ocr

Supports only POST requests. Note the host: this endpoint lives on opensolr.com, not on api.opensolr.com like the other AI endpoints, because the reading happens on the Solr fleet rather than on the GPU server.


Authentication & Core Parameters

Parameter Type Required Description
email string Yes Your Opensolr registration email address.
api_key string Yes Your API key from the Opensolr dashboard.
index_name string Yes Name of your Opensolr index the pictures belong to.

Image Parameters

Parameter Type Required Default Description
images array Yes 1 to 5 pictures, each as base64. A data: URI prefix is accepted. As a JSON body, or as a JSON string in a form field.

Every picture is checked by its content, never by its name: 20 MB ceiling, and the type is decided from the file's own bytes (JPEG, PNG, WebP, GIF, BMP, TIFF, JP2, HEIC/HEIF, AVIF).


Example

curl -s -X POST "https://opensolr.com/solr_manager/api/image_ocr" \
  -H "Content-Type: application/json" \
  -d "{\"email\":\"you@example.com\",\"api_key\":\"YOUR_API_KEY\",\"index_name\":\"my_index\",\"images\":[\"$(base64 -w0 receipt.jpg)\"]}"

Response

{
  "status": true,
  "charged": 1,
  "results": [
    {
      "status": true,
      "text": "PETROM STATION 1042\nBucuresti, Sos. Nordului 24\nBENZINA STANDARD 95\nTOTAL 300.86 LEI\nBON FISCAL 004417",
      "lines": ["PETROM STATION 1042", "Bucuresti, Sos. Nordului 24", "BENZINA STANDARD 95", "TOTAL 300.86 LEI", "BON FISCAL 004417"],
      "secs": 0.245,
      "lang": "eng+ron"
    }
  ]
}
Field Description
results One entry per picture, in the order you sent them.
status Per picture: true with the text, false with a msg saying why.
text Everything read, in reading order, one line per printed line.
lines The same reading as an array of lines — easier to index or to show.
cached Present and true when the picture had been read before, in which case it is free.
charged How many AI requests this call actually counted (see below).

What it costs

One AI request per picture the servers actually read. A picture answered from cache costs nothing, and a picture that could not be read costs nothing. Readings are kept permanently against the picture's own fingerprint, so sending the same receipt again is free.

On an Opensolr Photos index the reading is part of the photo's own tenth of a request and is not charged separately.

The endpoint needs a paid plan with vector search on it, like the other AI endpoints, and it counts against the same monthly allowance as every other AI endpoint. What your plan allows is on the API Quota tab of your dashboard.


Refusals

msg Meaning
IMAGES_MUST_BE_A_NON_EMPTY_ARRAY images was missing or empty.
MAX_5_IMAGES_PER_CALL More than five pictures in one call.
INVALID_IMAGE / UNSUPPORTED_IMAGE_TYPE_… The bytes are not a picture of a supported type.
IMAGE_TOO_LARGE_MAX_20_MB Over the size ceiling.
OCR_EMPTY The picture was read and carries no usable text. This is a real answer, not a failure.
OCR_UNAVAILABLE No reader answered. Nothing is charged; try again.
ERROR_NOT_CORE_OWNER The index does not belong to the account making the call.

Reading only the pictures worth reading

If you are indexing a whole library, do not send everything: ask image_clip (or image_index) first and look at text_like in its answer. It is true when the picture carries something text-like — a label, a document, a receipt, an invoice, a card, a ticket, a menu, a poster, a screenshot, a number — decided over the top 50 labels the model considered, not just the handful it returns. Send those to image_ocr and skip the rest; a wedding album costs you nothing that way, which is exactly what Opensolr Photos does.


Notes

  • Languages read today: English and Romanian (eng+ron), in one pass, with the reading tuned for sparse text — the mode that finds an article number next to a barcode.
  • Pictures are read in memory on a temporary file that is deleted immediately. Nothing is stored except the reading itself, in the cache, against the picture's fingerprint.
  • Barcodes and QR codes are not decoded by this endpoint. image_to_text returns those separately as codes.