Perplexity Contextualizedembeddings API

The Contextualizedembeddings API from Perplexity — 1 operation(s) for contextualizedembeddings.

OpenAPI Specification

perplexity-contextualizedembeddings-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Perplexity AI Agent Contextualizedembeddings API
  description: Perplexity AI API
  version: 1.0.0
servers:
- url: https://api.perplexity.ai
  description: Perplexity AI API
tags:
- name: Contextualizedembeddings
paths:
  /v1/contextualizedembeddings:
    post:
      summary: Create Contextualized Embeddings
      description: Generate contextualized embeddings for document chunks. Chunks from the same document share context awareness, improving retrieval quality for document-based applications.
      operationId: contextualized_embeddings_v1_contextualizedembeddings_post
      security:
      - HTTPBearer: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContextualizedEmbeddingsRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContextualizedEmbeddingsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      tags:
      - Contextualizedembeddings
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    EmbeddingObject:
      type: object
      title: Embedding Object
      description: A single embedding result
      properties:
        object:
          type: string
          title: Object
          description: The object type
          example: embedding
        index:
          type: integer
          title: Index
          description: The index of the input text this embedding corresponds to
        embedding:
          type: string
          title: Embedding
          description: '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).'
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
    ContextualizedEmbeddingsRequest:
      type: object
      title: Contextualized Embeddings Request
      description: Request body for creating contextualized embeddings
      required:
      - input
      - model
      properties:
        input:
          type: array
          title: Input
          description: 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.
          items:
            type: array
            items:
              type: string
              minLength: 1
            minItems: 1
          minItems: 1
          maxItems: 512
        model:
          type: string
          title: Model
          description: The contextualized embedding model to use
          enum:
          - pplx-embed-context-v1-0.6b
          - pplx-embed-context-v1-4b
        dimensions:
          type: integer
          title: Dimensions
          description: '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).'
          minimum: 128
          maximum: 2560
        encoding_format:
          type: string
          title: Encoding Format
          description: Output encoding format for embeddings. base64_int8 returns base64-encoded signed int8 values. base64_binary returns base64-encoded packed binary (1 bit per dimension).
          enum:
          - base64_int8
          - base64_binary
          default: base64_int8
    ContextualizedEmbeddingObject:
      type: object
      title: Contextualized Embedding Object
      description: A single contextualized embedding result
      properties:
        object:
          type: string
          title: Object
          description: The object type
          example: list
        index:
          type: integer
          title: Index
          description: The index of the document this chunk belongs to
        data:
          type: array
          title: Data
          description: List of embedding objects for chunks in this document
          items:
            $ref: '#/components/schemas/EmbeddingObject'
    ContextualizedEmbeddingsResponse:
      type: object
      title: Contextualized Embeddings Response
      description: Response body for contextualized embeddings request
      properties:
        object:
          type: string
          title: Object
          description: The object type
          example: list
        data:
          type: array
          title: Data
          description: List of contextualized embedding objects
          items:
            $ref: '#/components/schemas/ContextualizedEmbeddingObject'
        model:
          type: string
          title: Model
          description: The model used to generate embeddings
        usage:
          $ref: '#/components/schemas/EmbeddingsUsage'
    EmbeddingsUsage:
      type: object
      title: Embeddings Usage
      description: Token usage for the embeddings request
      properties:
        prompt_tokens:
          type: integer
          title: Prompt Tokens
          description: Number of tokens in the input texts
        total_tokens:
          type: integer
          title: Total Tokens
          description: Total number of tokens processed
        cost:
          type: object
          title: Cost
          description: Cost breakdown for the request
          properties:
            input_cost:
              type: number
              title: Input Cost
              description: Cost for input tokens in USD
            total_cost:
              type: number
              title: Total Cost
              description: Total cost for the request in USD
            currency:
              type: string
              title: Currency
              description: Currency of the cost values
              enum:
              - USD
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer