Skip to main content
Perplexity

Search documentation

Type to search this documentation.

Create Embeddings

POST/v1/embeddingsCreate Embeddings

Generate embeddings for a list of texts. Use these embeddings for semantic search, clustering, and other machine learning applications.

Request body

required
application/json
objectEmbeddingsRequest

Embeddings Request

Request body for creating embeddings

dimensionsinteger

Number of dimensions for output embeddings (Matryoshka). Range: 128-1024 for pplx-embed-v1-0.6b, 128-2560 for pplx-embed-v1-4b. Defaults to full dimensions (1024 or 2560).

maximum 2560 · minimum 128

encoding_formatstring

Output encoding format for embeddings. base64_int8 returns base64-encoded signed int8 values. base64_binary returns base64-encoded packed binary (1 bit per dimension).

one of "base64_int8", "base64_binary" · default "base64_int8"

inputvaluerequired

Input text to embed, encoded as a string or array of strings. Maximum 512 texts per request. Each input must not exceed 32K tokens. All inputs in a single request must not exceed 120,000 tokens combined. Empty strings are not allowed.

Show child attributes
oneOf · 2 options
Option 1string

minLength 1

Option 2array of string

maxItems 512 · minItems 1

modelstringrequired

The embedding model to use

one of "pplx-embed-v1-0.6b", "pplx-embed-v1-4b"

Example request
{
  "dimensions": 0,
  "encoding_format": "base64_int8",
  "input": "string",
  "model": "pplx-embed-v1-0.6b"
}

Responses

200Successful Responseapplication/json
objectEmbeddingsResponse

Embeddings Response

Response body for embeddings request

dataarray of object

List of embedding objects

Show child attributes
Show array items

A single embedding result

embeddingstring

Base64-encoded embedding vector. For base64_int8: decode to signed int8 array (length = dimensions). For base64_binary: decode to packed bits (length = dimensions / 8 bytes).

indexinteger

The index of the input text this embedding corresponds to

objectstring

The object type

modelstring

The model used to generate embeddings

objectstring

The object type

usageobject

Token usage for the embeddings request

Show child attributes
costobject

Cost breakdown for the request

Show child attributes
currencystring

Currency of the cost values

one of "USD"

input_costnumber

Cost for input tokens in USD

total_costnumber

Total cost for the request in USD

prompt_tokensinteger

Number of tokens in the input texts

total_tokensinteger

Total number of tokens processed

Example response
{
  "data": [
    {
      "embedding": "string",
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "string",
  "object": "list",
  "usage": {
    "cost": {
      "currency": "USD",
      "input_cost": 0,
      "total_cost": 0
    },
    "prompt_tokens": 0,
    "total_tokens": 0
  }
}
422Validation Errorapplication/json
objectHTTPValidationError

HTTPValidationError

detailarray of object
Show child attributes
Show array items
locarray of valuerequired
Show child attributes
Show array items
anyOf · 2 options
Option 1string
Option 2integer
msgstringrequired
typestringrequired
Example response
{
  "detail": [
    {
      "loc": [
        0
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
Documentation menu