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 openai/text-embedding-3-small, 3072 for google/gemini-embedding-001, 4096 for qwen/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.

Fall back to another model

List up to three fallback models in models, in the order to try them. If no provider of the model you asked for returns vectors, NagaAI sends the same input to the next model. The model field in the response names the model that answered. Vectors from different models live in different spaces. List only models whose vectors you can compare with the ones you store, such as models of the same family and size. With the OpenAI SDKs, pass the list in extra_body. Routing explains when NagaAI moves on and what you pay.

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.