AI API - Alt text for a picture (image_alt_text)

AI API: Vectors, Images & LLM

Writes the alternative text of a picture, following your own instruction: Opensolr reads what the picture shows and the text printed in it, then writes the alt text.

Endpointhttps://api.opensolr.com/solr_manager/api/image_alt_text
MethodPOST: multipart, form fields or a JSON body
Authemail and api_key of your account, as GET or POST parameters: Authentication.

01 · Parameters

index_nameRequired

Your index. Its owner's AI allowance is used.

imageRequired

The picture: a multipart file, or its base64. At most 20 MB.

promptRequired

Your instruction, up to 4000 characters, for example Write the alt text in one sentence, under 125 characters..

languageOptional

The language of the alt text. Default English.

02 · Example

curl -s -X POST "https://api.opensolr.com/solr_manager/api/image_alt_text" \
  -F "email=YOUR_EMAIL" -F "api_key=YOUR_API_KEY" -F "index_name=my_index" \
  -F "prompt=Write the alt text in one sentence, under 125 characters." -F "language=English" \
  -F "image=@photo.jpg"

03 · Answer

{
    "status": true,
    "text": "A red bicycle leaning against a brick wall on a city street.",
    "caption": "a red bicycle parked on a street",
    "cached": false
}

text is the alt text, caption what the picture model saw. The same picture with the same instruction is answered from cache, cached: true, and costs nothing. Values shown are an example.

Reading the picture and writing the text count against the AI allowance. Every plan includes a monthly allowance of AI requests: API Quota, Pricing. The allowance used is the one of the account that owns the index.

04 · Errors

INVALID_IMAGEHTTP 400

No picture, or not clean base64.

UPLOAD_FAILEDHTTP 400

The multipart upload did not arrive whole.

IMAGE_TOO_LARGE_MAX_20_MBHTTP 413

The picture is larger than 20 MB.

UNSUPPORTED_IMAGE_TYPE_...HTTP 415

Not a JPEG, PNG, WebP, GIF, BMP, TIFF, JPEG 2000, HEIC, HEIF or AVIF picture. The type is read from the bytes, not from the name.

ERROR_PROMPT_REQUIREDHTTP 200

No prompt.

VECTOR_NOT_ALLOWEDHTTP 200

AI is switched off on the plan of the index owner.

ERROR_AI_MONTHLY_QUOTA_EXCEEDEDHTTP 200

The monthly AI allowance is used up.

ERROR_NOT_CORE_OWNERHTTP 200

The index is not yours.

IMAGE_TO_TEXT_FAILED, AI_GENERATION_FAILEDHTTP 200

The picture could not be read, or the text could not be written. Retry.

WRONG_API_HOSTHTTP 404

Called on opensolr.com.

ERROR_AUTHENTICATION_FAILEDHTTP 403

The email and API key do not match.

05 · Related

What pictures get on crawled and pushed pages: Pictures described by what they show.

Every error code and HTTP status of the API: API errors. Calls per minute and per hour: Rate limits.