/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 aninput (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 toinput 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 thedata 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 to1.0 means the texts are semantically similar.
python
