Embeddings API
The Embeddings API encodes any text into a vector using state-of-the-art NLP machine learning models. It can be used to power semantic search, text comparison tools (also check out our Text Similarity API), recommendation engines, and much more.
Checking API status...
/v1/embeddings POST
https://api.api-ninjas.com/v1/embeddings
Returns a 768-dimensional vector as an array that encodes the meaning of any given input text.
Parameters
textrequiredQuery text to embed. Maximum 5000 characters.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Sample Request Live Demo!
text
https://api.api-ninjas.com/v1/embeddingsHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
JSON
1
2
3
4
5
6
7
8
9
10
11
{
"embeddings": [
0.013939207419753075,
-0.07620275765657425,
-0.014649288728833199,
-0.00781314168125391,
-0.0740455836057663,
0.03170469030737877,
...
]
}Code Examples
1
2
3
4
curl -X POST "https://api.api-ninjas.com/v1/embeddings" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "This is an example sentence."}'If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.