---
title: "Create Contextualized Embeddings"
method: POST
path: "/v1/contextualizedembeddings"
---

# Create Contextualized Embeddings

`POST /v1/contextualizedembeddings`

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

## Request body

- ContextualizedEmbeddingsRequest — Request body for creating contextualized embeddings
  - `input` array[], required — 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.
    - string[]
  - `model` 'pplx-embed-context-v1-0.6b' | 'pplx-embed-context-v1-4b', required — The contextualized embedding model to use
  - `dimensions` integer — 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).
  - `encoding_format` 'base64_int8' | 'base64_binary' — Output encoding format for embeddings. base64_int8 returns base64-encoded signed int8 values. base64_binary returns base64-encoded packed binary (1 bit per dimension).

## Response `200`

Successful Response

- ContextualizedEmbeddingsResponse — Response body for contextualized embeddings request
  - `object` string — The object type
  - `data` ContextualizedEmbeddingObject[] — List of contextualized embedding objects
    - `object` string — The object type
    - `index` integer — The index of the document this chunk belongs to
    - `data` EmbeddingObject[] — List of embedding objects for chunks in this document
      - `object` string — The object type
      - `index` integer — The index of the input text this embedding corresponds to
      - `embedding` string — 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).
  - `model` string — The model used to generate embeddings
  - `usage` EmbeddingsUsage — Token usage for the embeddings request
    - `prompt_tokens` integer — Number of tokens in the input texts
    - `total_tokens` integer — Total number of tokens processed
    - `cost` object — Cost breakdown for the request
      - `input_cost` number — Cost for input tokens in USD
      - `total_cost` number — Total cost for the request in USD
      - `currency` 'USD' — Currency of the cost values

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/perplexityai/apis/perplexity-ai-api.md) · [All operations](https://skmtc.net/perplexityai/apis/perplexity-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/perplexityai/perplexity-ai-api/versions/bcca72d3b564/schema)
