Skip to main content

POST /v1/embeddings

Converts input into a high-dimensional vector representation (embedding). Embeddings are used for semantic search, clustering, classification, and retrieval-augmented generation (RAG). The gateway supports text, image, and video embedding inputs depending on the provider. The response always includes a data array with embedding vectors indexed to match the input.

Request headers

string
The provider to route the request to (e.g. openai, cohere, google-vertex-ai). Required when not using a config.
string
Your provider API key.
string
A JSON config object or config ID that defines routing, fallbacks, retries, and more.
string
A virtual key ID from Portkey Cloud.

Request body

string
required
The embedding model to use (e.g. text-embedding-3-small, embed-english-v3.0).
string | string[] | object[]
required
The text or texts to embed. Accepts:
  • A single string
  • An array of strings for batch embedding
  • An array of EmbedInput objects with text, image, or video fields for multimodal providers
string
default:"float"
The format of the returned embeddings. One of float or base64.
integer
The number of dimensions in the output embedding. Only supported by models that accept a dimensions parameter (e.g. text-embedding-3-small).
string
A unique identifier for the end user, used for monitoring.

Response

string
Always list.
object[]
An array of embedding objects, one per input item, in the same order as the input.
string
The model used to generate the embeddings.
object
Token usage for this request.

Code examples