Opensolr API Endpoint: image_to_text
Overview
The image_to_text endpoint turns a picture into words. You upload an image, and you get back the names of the things in it and one sentence describing it, ready to be used as an ordinary search query.
This is what powers search by image on Opensolr hosted search pages: the visitor uploads a photo, the words come back, and the normal search runs with those words. Nothing about your index changes — no new fields, no image vectors, no re-indexing.
Two readers work on every picture at the same time. An image model (Florence-2) names the objects it finds in the picture and writes one sentence about it, in its own words, with no fixed list of concepts. At the same time the picture is read with OCR (tesseract, on the CPUs of api.opensolr.com). When the OCR reads real text in it (a product label, a receipt, a document, a poster: at least four confidently read words of three letters or more), that text becomes the query instead of the model's words. See mode below. When it reads nothing worth keeping, the query is the model's words. If you only need the printed text, call image_ocr directly, which takes ten pictures per call.
Every picture is also checked for a barcode or QR code. When one is found it is decoded and handed back as its own field, codes — it is never mixed into the search query. So there are three layers working on every image: what it looks like, what is printed on it, and any code on it.
Endpoint URL
https://api.opensolr.com/solr_manager/api/image_to_text
Supports only POST requests.
Authentication & Core Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| 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/core to use. |
Image Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| image | file | Yes* | – | The image itself, sent as a normal multipart/form-data file upload. |
| image | string | Yes* | – | Alternatively, the image as base64. A data: URI prefix is accepted. |
| images | array | Yes* | – | Ten pictures in one call: 1 to 10 base64 pictures, as a JSON body or a JSON string in a form field. The answer then carries a results array with one slot per picture, in the order you sent them, and a charged total. |
| top_k | integer | No | 12 | Accepted for compatibility. The image model returns the objects it finds in the picture, up to five, whatever the value. |
* Send image (a file or base64) for one picture, or images for up to ten. The single-picture answer is unchanged: the object itself, no wrapper. If both image and an uploaded file are present, the uploaded file wins.
Example: file upload
curl -X POST "https://api.opensolr.com/solr_manager/api/image_to_text" \ -F "email=YOUR_EMAIL" \ -F "api_key=YOUR_API_KEY" \ -F "index_name=YOUR_INDEX" \ -F "image=@/path/to/photo.jpg"
Example: base64
curl -X POST "https://api.opensolr.com/solr_manager/api/image_to_text" \ --data-urlencode "email=YOUR_EMAIL" \ --data-urlencode "api_key=YOUR_API_KEY" \ --data-urlencode "index_name=YOUR_INDEX" \ --data-urlencode "image@/path/to/photo.b64"
Response
{ "text": "lion, A lion lying in the grass next to a tree.", "mode": "clip", "caption": "A lion lying in the grass next to a tree.", "ocr_text": "", "ocr_title": "", "ocr_codes": [], "codes": [], "labels": [ { "label": "lion", "score": 1.0 } ], "thumb_b64": "…", "preview_b64": "…", "model": "florence-community/Florence-2-base", "vocabulary_size": 0, "ocr_ms": 240, "codes_ms": 12, "took_ms": 310 }
| Field | Description |
|---|---|
| text | The finished query — feed this straight into your search. Depending on mode it is the object names and the sentence joined with , , or the text read off the picture. |
| mode | clip: the picture is a thing and text is what the image model saw. ocr: the OCR read real text in the picture (a label, a shelf tag, a receipt, a document); the model's words are dropped and text is the largest print on it plus any article, model or EAN style codes. An ocr query is exact tokens, so run it lexical rather than hybrid — that is what the hosted search page does automatically. |
| caption | The one sentence the image model wrote about the picture. |
| ocr_text | Everything the OCR read, cleaned up. Empty when it read nothing. |
| ocr_title | The largest print in the picture: the product name on a label, the headline on a poster. This is what text starts with in ocr mode. |
| ocr_codes | Article, model or EAN style tokens read off the picture (6048297, G1-88-E), up to three. Appended to text. |
| codes | Any barcode or QR code found on the picture: [{ "type": "...", "text": "..." }]. Checked on every image regardless of mode, empty when none is found. Never part of text — open the value if it is a URL, or search for it as an exact code, on your own. |
| labels | The objects the image model found in the picture, up to five, each with a score of 1.0 (the model names objects, it does not rank them). Always the visual answer, whatever mode is. |
| thumb_b64 | A 320px JPEG preview of what was received, base64. Useful for showing the visitor which picture produced the results. |
| preview_b64 | A larger 1400px JPEG preview, base64. |
| model | The image model that produced caption and labels. |
| vocabulary_size | Always 0: the image model describes the picture in its own words, not from a fixed list. |
| ocr_ms | Milliseconds spent reading text. The OCR runs on every picture, alongside the image model. |
| codes_ms | Milliseconds spent scanning for a barcode or QR code. |
| took_ms | Server-side processing time in milliseconds. |
Using it for search
The whole point is that the output is plain text, so it goes through your existing search unchanged:
# 1. Describe the image WORDS=$(curl -s -X POST "https://api.opensolr.com/solr_manager/api/image_to_text" \ -F "email=YOUR_EMAIL" -F "api_key=YOUR_API_KEY" \ -F "index_name=YOUR_INDEX" \ -F "image=@photo.jpg" | jq -r .text) # 2. Search with them, exactly like a typed query curl -s "https://api.opensolr.com/solr_manager/api/embed_and_search" \ --data-urlencode "email=YOUR_EMAIL" \ --data-urlencode "api_key=YOUR_API_KEY" \ --data-urlencode "index_name=YOUR_INDEX" \ --data-urlencode "fresh=no" \ --data-urlencode "q=$WORDS"
Because the query is text, it runs like a typed search: on the hosted search page with everything set up there, or through embed_and_search with the Search Tuning of your index.
Accepted images
| Limit | Value |
|---|---|
| Maximum size | 20 MB |
| Formats | JPEG, PNG, WEBP, GIF, BMP, TIFF, JPEG 2000, HEIC/HEIF, AVIF |
| Maximum pixels | 50 megapixels |
The format is determined from the content of the file, never from its name or from the Content-Type header you send. A file named photo.png that is not really an image is rejected. Animated images are read as their first frame, and EXIF metadata (including any GPS coordinates) is discarded during processing.
Errors
| HTTP | Meaning |
|---|---|
| 400 | No image supplied, invalid base64, or the file could not be decoded. |
| 413 | The image is larger than 20 MB, or declares more pixels than allowed. |
| 415 | The file is not an image, or is in a format that is not accepted. |
| 429 | Rate limit or monthly AI request cap reached. |
Special Notes
- Each picture counts as one AI request against your monthly AI quota: 0.5 for reading its text (OCR) and 0.5 for working out what it shows. A picture answered from cache counts nothing. With
images,chargedsays how many the call counted.
Every plan includes a monthly AI allowance of 500 AI requests; see pricing and API Quota.
- The endpoint is rate limited per minute and per hour like every other Opensolr API endpoint.
- If you use a scoped API key, tick image_to_text in the key's scopes, otherwise the call returns
ERROR_SCOPED_KEY_ENDPOINT_NOT_ALLOWED. - Your image is not stored. It is processed in memory and discarded; the previews returned to you are freshly encoded copies.
- The object names and the sentence are English. Vector search crosses languages on its own, so English words still retrieve documents written in other languages. The OCR reads English and Romanian.
- This endpoint lives on
api.opensolr.com, like every other AI endpoint.