AI API - Language, sentiment and vectors for your texts (enrich_text)

AI API: Vectors, Images & LLM

Gives you, for up to 50 texts, what Opensolr adds to every document it indexes: the language, the locale, the sentiment and, if you ask, the meaning vector. Nothing is written to your index.

Endpointhttps://api.opensolr.com/solr_manager/api/enrich_text
MethodPOST, 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 pays for the vectors.

itemsRequired

Up to 50 texts, each {id, title, description, text, uri, language, locale}. All fields are optional; id comes back as you sent it.

vectorsOptional

1: also the meaning vector of each item.

02 · Example

curl -s -X POST "https://api.opensolr.com/solr_manager/api/enrich_text" \
  -H "Content-Type: application/json" \
  -d '{"email": "YOUR_EMAIL", "api_key": "YOUR_API_KEY", "index_name": "my_index", "vectors": 1,
       "items": [{"id": "a1", "title": "Great service", "description": "The team answered within minutes and fixed everything."}]}'

03 · Answer

{
    "status": true,
    "vectors": true,
    "vectors_error": false,
    "results": [
        {
            "id": "a1",
            "sent_neg": 0,
            "sent_neu": 0.52,
            "sent_pos": 0.48,
            "sent_com": 0.84,
            "meta_detected_language": "en",
            "meta_language": "en",
            "embeddings": [
                0.0132,
                -0.0418,
                "..."
            ]
        }
    ]
}

The language comes from your language or locale when you send one, else it is detected from title and description, else read from a locale in the uri path. meta_og_locale is there when a locale is known.

The sentiment is scored from title, description and text: sent_com runs from -1 (negative) to 1 (positive). It is measured on English text.

vectors says whether vectors were made: only when the plan of the index owner has AI and allowance left. An item with less than 50 characters of text gets none. vectors_error is true when the vector service failed.

Values shown are an example.

Language and sentiment are free; each vector the model makes counts one AI request, and a vector made before costs nothing. 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

ERROR_ITEMS_MUST_BE_A_NON_EMPTY_ARRAYHTTP 200

No items.

ERROR_MAX_50_ITEMS_PER_CALLHTTP 200

More than 50 items.

ERROR_NOT_CORE_OWNERHTTP 200

The index is not yours.

WRONG_API_HOSTHTTP 404

Called on opensolr.com.

ERROR_AUTHENTICATION_FAILEDHTTP 403

The email and API key do not match.

05 · Related

Vectors alone: batch_embed. The fields themselves: Language and locale, Sentiment.

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