Skip to main content
The /v1/embeddings endpoint converts text into numerical vectors that capture semantic meaning. You can embed a single string or a batch of strings in one request. The resulting vectors are suitable for semantic search, retrieval-augmented generation (RAG), clustering, and classification tasks.

Authentication

Include your API key in every request:

Send an embeddings request

Provide an input (a string or array of strings) and a model. TokModel routes the request to the specified embedding model and returns one vector per input item.

Embed multiple inputs in one request

Pass an array of strings to input to embed a batch in a single API call. The response contains one entry per input, in the same order.

Example response

Each object in the data array corresponds to one input string. The embedding field contains the raw float vector.
The embedding array above is truncated for readability. Real vectors typically contain 512 to 3072 dimensions depending on the model.

Compute cosine similarity

After embedding two pieces of text, compare them with cosine similarity. A score close to 1.0 means the texts are semantically similar.
python

Common use cases

Semantic search — embed a user query and compare it against pre-embedded documents to find the most relevant results, even when the exact words differ. Retrieval-augmented generation (RAG) — embed your knowledge base and retrieve the top-k matching chunks before passing them to a chat model as context. Clustering — group similar documents together by clustering their vectors using algorithms like k-means without any labeled training data. Classification — train a lightweight classifier on top of embeddings to categorize text into predefined labels.