Skip to main content
Perplexity

Search documentation

Type to search this documentation.

Create Contextualized Embeddings

POST/v1/contextualizedembeddingsCreate Contextualized Embeddings

Generate contextualized embeddings for document chunks. Chunks from the same document share context awareness, improving retrieval quality for document-based applications.

Request body

required
application/json
objectContextualizedEmbeddingsRequest

Contextualized Embeddings Request

Request body for creating contextualized embeddings

dimensionsinteger

Number of dimensions for output embeddings (Matryoshka). Range: 128-1024 for pplx-embed-context-v1-0.6b, 128-2560 for pplx-embed-context-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"

inputarray of array of stringrequired

Nested array structure where each inner array contains chunks from a single document. Chunks within the same document are encoded with document-level context awareness. Maximum 512 documents. Total chunks across all documents must not exceed 16,000. Total tokens per document must not exceed 32K. All chunks in a single request must not exceed 120,000 tokens combined. Empty strings are not allowed.

maxItems 512 · minItems 1

Show child attributes

maxItems 512 · minItems 1

Show array items

minItems 1

modelstringrequired

The contextualized embedding model to use

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

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

Responses

200Successful Responseapplication/json
objectContextualizedEmbeddingsResponse

Contextualized Embeddings Response

Response body for contextualized embeddings request

dataarray of object

List of contextualized embedding objects

Show child attributes
Show array items

A single contextualized embedding result

dataarray of object

List of embedding objects for chunks in this document

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

indexinteger

The index of the document this chunk belongs 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": [
    {
      "data": [
        {
          "embedding": "string",
          "index": 0,
          "object": "embedding"
        }
      ],
      "index": 0,
      "object": "list"
    }
  ],
  "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