curl --request POST \
--url https://api.perplexity.ai/v1/contextualizedembeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": [
[
"<string>"
]
],
"model": "pplx-embed-context-v1-0.6b"
}
'{
"object": "list",
"data": [
{
"object": "list",
"index": 123,
"data": [
{
"object": "embedding",
"index": 123,
"embedding": "<string>"
}
]
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123,
"cost": {
"input_cost": 123,
"total_cost": 123,
"currency": "USD"
}
}
}Generate contextualized embeddings for document chunks. Chunks from the same document share context awareness, improving retrieval quality for document-based applications.
curl --request POST \
--url https://api.perplexity.ai/v1/contextualizedembeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": [
[
"<string>"
]
],
"model": "pplx-embed-context-v1-0.6b"
}
'{
"object": "list",
"data": [
{
"object": "list",
"index": 123,
"data": [
{
"object": "embedding",
"index": 123,
"embedding": "<string>"
}
]
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123,
"cost": {
"input_cost": 123,
"total_cost": 123,
"currency": "USD"
}
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Request body for creating contextualized embeddings
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.
1 - 512 elements11The contextualized embedding model to use
pplx-embed-context-v1-0.6b, pplx-embed-context-v1-4b 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).
128 <= x <= 2560Output encoding format for embeddings. base64_int8 returns base64-encoded signed int8 values. base64_binary returns base64-encoded packed binary (1 bit per dimension).
base64_int8, base64_binary Successful Response
Response body for contextualized embeddings request
Was this page helpful?