Skip to main content
Send text to POST /v1/embeddings and NagaAI returns one vector per input. Texts with similar meaning get vectors that point the same way, so you can rank documents against a query by comparing vectors. The endpoint follows the OpenAI Embeddings format, and the OpenAI SDK works unchanged. Choose a model whose operations include embeddings in GET /v1/models.

Rank documents against a query

The example embeds a search query together with three support articles, then sorts the articles by cosine similarity to the query.
The password article should score highest, because its meaning is closest to the query even though it shares almost no words with it.

Read the response

data holds one entry per input. Match each vector to its input by index, not by position. usage.prompt_tokens is what the request bills on. The embedding array below is shortened to three numbers for the page:

Choose the input and the vector format

input is a string, a list of strings, a list of token ids, or a list of such lists. Send many texts in one request instead of one request per text. Vector lengths differ by model: 1536 for text-embedding-3-small, 3072 for gemini-embedding-001, 4096 for qwen3-embedding-8b. Compare vectors only when they come from the same model and the same dimensions, because vectors from different models live in different spaces.

Billing

NagaAI charges embeddings per input token, at the token row of pricing in GET /v1/models. Embeddings have no output tokens.

Troubleshooting

400 model_not_found

The model does not exist or has no embeddings operation. A chat model fails here too. Check the model’s operations in GET /v1/models.

Vectors of different lengths

Two models, or one model with and without dimensions, produce vectors of different lengths. Embed your documents and your queries with the same model and the same dimensions.

dimensions has no effect

The provider that served the request has no such parameter, so NagaAI dropped the field and the vector came back at full length. Pick a model that supports dimensions, or keep the full length.