Skip to main content
The embeddings endpoint converts text into numeric vector representations that capture its semantic meaning. Two pieces of text with similar meanings will have embedding vectors that are close together in vector space, regardless of the exact words used. You can use embeddings for semantic search, document clustering, duplicate detection, and retrieval-augmented generation (RAG) — anywhere you need to measure or compare the meaning of text.

Endpoint

Request Parameters

string
required
The embedding model ID in provider/model format. Recommended options:
  • openai/text-embedding-3-small — fast and cost-effective, 1536 dimensions by default
  • openai/text-embedding-3-large — highest accuracy, 3072 dimensions by default
Use GET /v1/models with ?provider=openai to see all available embedding models.
string | array
required
The text or texts to embed. Pass a single string to embed one piece of text, or an array of strings to embed multiple texts in a single API call. Batching is more efficient than making one request per string.
string
default:"float"
The format of the returned embedding values. Use "float" for a standard JSON array of floating-point numbers (the default), or "base64" for a base64-encoded binary representation that is more compact over the wire.
integer
The number of dimensions to include in the output embedding. Supported only by text-embedding-3 models. Reducing dimensions lowers storage and compute costs at some accuracy cost.

Request Example

cURL

Response Fields

string
Always "list".
array
An array of embedding objects, one per input string, in the same order as the input array.
string
The model ID used to generate the embeddings.
integer
The total number of tokens across all input strings.
integer
The same as prompt_tokens for embeddings — there are no completion tokens.

Response Example

The embedding array is truncated above for readability. In a real response, it contains 1536 floating-point numbers for text-embedding-3-small (or 3072 for text-embedding-3-large). Every value is a number — the "..." placeholder above is not part of the actual JSON.

Common Use Cases

  • Semantic search — embed your documents once, store the vectors in a vector database, then embed a query and retrieve the most similar documents using nearest-neighbour search.
  • Retrieval-augmented generation (RAG) — combine semantic search with a language model to answer questions grounded in your own documents.
  • Document clustering — group large collections of text by topic without manually labelling them.
  • Duplicate detection — find near-duplicate documents by comparing embedding similarity, even when the wording differs.

Python Example

The example below embeds a list of sentences using the openai SDK pointed at Portrix, then computes cosine similarity between pairs to find the most semantically related sentences.
Python
For production RAG systems, store your embedding vectors in a dedicated vector database such as Pinecone, Weaviate, or pgvector (PostgreSQL). These databases are optimised for approximate nearest-neighbour search at scale.