How Embeddings Work
When you send text to the embeddings endpoint, the underlying AI model processes the text and outputs a list of floating-point numbers (a vector). Texts with similar meanings will have vectors that are numerically “closer” to each other in the high-dimensional space. The NeosantaraAI API provides an/v1/embeddings
endpoint to generate these vectors.
Usage
To generate embeddings, send a POST request to the/v1/embeddings
endpoint with your text input.
Endpoint
POST /v1/embeddings
Request Body
Parameters
input
(string or array of strings, required): The text(s) to embed. Can be a single string or an array of strings.model
(string, optional, default:"nusa-embedding-0001"
): The ID of the embedding model to use.encoding_format
(string, optional, default:"float"
): The format of the returned embeddings. Currently,"float"
is the primary supported format.
Supported Embedding Models
The NusantaraAI API supports various embedding models, often utilizing intelligent fallbacks to ensure reliability. Some of the available models include:nusa-embedding-0001
: The primary embedding model, offering good performance for general-purpose embeddings.
Example Response
Python and JavaScript Examples (with OpenAI SDK)
You can generate embeddings using the OpenAI SDK by configuring itsbase_url
to point to the NeosantaraAI API.