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.
From 4,698 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 331ms | 343ms | 388ms | 636ms | 1215ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/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.
Response
A JSON object with the following fields or an error if the request is unsuccessful.
embeddingsArray of floating-point numbers representing the text embedding vector.
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/embeddingsHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
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.
Frequently Asked Questions
Can I use the Embeddings API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Embeddings API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Embeddings API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Embeddings API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.What are some use cases for the Embeddings API?
The Embeddings API encodes text into vectors using state-of-the-art NLP machine learning models, making it ideal for semantic search, recommendation engines, clustering, and text comparison tools. For directly scoring how alike two pieces of text are, you can also pair it with our Text Similarity API, or explore other NLP tools on the APIs page.How do I send text to embed, and is there a length limit?
Send a POST request to/v1/embeddingswith a JSON body containing thetextparameter, which is required and accepts a maximum of 5000 characters. See the error codes page for details on responses to invalid input.What does the Embeddings API response include?
The response is a JSON object with anembeddingsfield, a 768-dimensional array of floating-point numbers that encodes the meaning of your input text. These vectors can feed downstream tasks such as those handled by our Sentiment API or Text Language API.How many dimensions does each embedding vector have?
Every call to/v1/embeddingsreturns a 768-dimensional vector as an array in theembeddingsfield, regardless of input length. Review your plan options on the pricing page before integrating at scale.