Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.23.2"
".": "0.24.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 6
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-3ee0511fa1bf59b2bb44d947f7d884fd8522ef872d33bab141874941b76f1dd7.yml
openapi_spec_hash: 394bbfe74954625b70de9c85d553e3d0
config_hash: c7d506cdee510785b58defa1a626e20b
configured_endpoints: 8
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-78325ecc9bdc8e9850866fcdd3be3d209b06f151059c774afc7e6005a1775f09.yml
openapi_spec_hash: 19a34c8ddd46f81dd0b0850af5ee42f3
config_hash: c3b93f1bb8fa365d5a83e83b7e13e6c4
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.24.0 (2026-02-12)

Full Changelog: [v0.23.2...v0.24.0](https://github.com/perplexityai/perplexity-node/compare/v0.23.2...v0.24.0)

### Features

* **api:** Add Embeddings API ([393ccb6](https://github.com/perplexityai/perplexity-node/commit/393ccb6f22165349a70c873f6c260dc756276c1c))

## 0.23.2 (2026-02-11)

Full Changelog: [v0.23.1...v0.23.2](https://github.com/perplexityai/perplexity-node/compare/v0.23.1...v0.23.2)
Expand Down
23 changes: 23 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Types:
- <code><a href="./src/resources/shared.ts">ChatMessageInput</a></code>
- <code><a href="./src/resources/shared.ts">ChatMessageOutput</a></code>
- <code><a href="./src/resources/shared.ts">Choice</a></code>
- <code><a href="./src/resources/shared.ts">ContextualizedEmbeddingObject</a></code>
- <code><a href="./src/resources/shared.ts">EmbeddingObject</a></code>
- <code><a href="./src/resources/shared.ts">EmbeddingsUsage</a></code>
- <code><a href="./src/resources/shared.ts">JsonSchemaFormat</a></code>
- <code><a href="./src/resources/shared.ts">ResponseFormat</a></code>
- <code><a href="./src/resources/shared.ts">SearchResult</a></code>
Expand Down Expand Up @@ -55,6 +58,26 @@ Methods:

- <code title="post /v1/responses">client.responses.<a href="./src/resources/responses.ts">create</a>({ ...params }) -> ResponseCreateResponse</code>

# Embeddings

Types:

- <code><a href="./src/resources/embeddings.ts">EmbeddingCreateResponse</a></code>

Methods:

- <code title="post /v1/embeddings">client.embeddings.<a href="./src/resources/embeddings.ts">create</a>({ ...params }) -> EmbeddingCreateResponse</code>

# ContextualizedEmbeddings

Types:

- <code><a href="./src/resources/contextualized-embeddings.ts">ContextualizedEmbeddingCreateResponse</a></code>

Methods:

- <code title="post /v1/contextualizedembeddings">client.contextualizedEmbeddings.<a href="./src/resources/contextualized-embeddings.ts">create</a>({ ...params }) -> ContextualizedEmbeddingCreateResponse</code>

# Async

## Chat
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@perplexity-ai/perplexity_ai",
"version": "0.23.2",
"version": "0.24.0",
"description": "The official TypeScript library for the Perplexity API",
"author": "Perplexity <api@perplexity.ai>",
"types": "dist/index.d.ts",
Expand Down
25 changes: 25 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import * as Errors from './core/error';
import * as Uploads from './core/uploads';
import * as API from './resources/index';
import { APIPromise } from './core/api-promise';
import {
ContextualizedEmbeddingCreateParams,
ContextualizedEmbeddingCreateResponse,
ContextualizedEmbeddings,
} from './resources/contextualized-embeddings';
import { EmbeddingCreateParams, EmbeddingCreateResponse, Embeddings } from './resources/embeddings';
import {
Annotation,
ContentPart,
Expand Down Expand Up @@ -743,12 +749,16 @@ export class Perplexity {
chat: API.Chat = new API.Chat(this);
search: API.Search = new API.Search(this);
responses: API.Responses = new API.Responses(this);
embeddings: API.Embeddings = new API.Embeddings(this);
contextualizedEmbeddings: API.ContextualizedEmbeddings = new API.ContextualizedEmbeddings(this);
async: API.Async = new API.Async(this);
}

Perplexity.Chat = Chat;
Perplexity.Search = Search;
Perplexity.Responses = Responses;
Perplexity.Embeddings = Embeddings;
Perplexity.ContextualizedEmbeddings = ContextualizedEmbeddings;
Perplexity.Async = Async;

export declare namespace Perplexity {
Expand Down Expand Up @@ -780,12 +790,27 @@ export declare namespace Perplexity {
type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming,
};

export {
Embeddings as Embeddings,
type EmbeddingCreateResponse as EmbeddingCreateResponse,
type EmbeddingCreateParams as EmbeddingCreateParams,
};

export {
ContextualizedEmbeddings as ContextualizedEmbeddings,
type ContextualizedEmbeddingCreateResponse as ContextualizedEmbeddingCreateResponse,
type ContextualizedEmbeddingCreateParams as ContextualizedEmbeddingCreateParams,
};

export { Async as Async };

export type APIPublicSearchResult = API.APIPublicSearchResult;
export type ChatMessageInput = API.ChatMessageInput;
export type ChatMessageOutput = API.ChatMessageOutput;
export type Choice = API.Choice;
export type ContextualizedEmbeddingObject = API.ContextualizedEmbeddingObject;
export type EmbeddingObject = API.EmbeddingObject;
export type EmbeddingsUsage = API.EmbeddingsUsage;
export type JsonSchemaFormat = API.JsonSchemaFormat;
export type ResponseFormat = API.ResponseFormat;
export type SearchResult = API.SearchResult;
Expand Down
83 changes: 83 additions & 0 deletions src/resources/contextualized-embeddings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../core/resource';
import * as Shared from './shared';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';

export class ContextualizedEmbeddings extends APIResource {
/**
* Generate contextualized embeddings for document chunks. Chunks from the same
* document share context awareness, improving retrieval quality for document-based
* applications.
*/
create(
body: ContextualizedEmbeddingCreateParams,
options?: RequestOptions,
): APIPromise<ContextualizedEmbeddingCreateResponse> {
return this._client.post('/v1/contextualizedembeddings', { body, ...options });
}
}

/**
* Response body for contextualized embeddings request
*/
export interface ContextualizedEmbeddingCreateResponse {
/**
* List of contextualized embedding objects
*/
data?: Array<Shared.ContextualizedEmbeddingObject>;

/**
* The model used to generate embeddings
*/
model?: string;

/**
* The object type
*/
object?: string;

/**
* Token usage for the embeddings request
*/
usage?: Shared.EmbeddingsUsage;
}

export interface ContextualizedEmbeddingCreateParams {
/**
* 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.
*/
input: Array<Array<string>>;

/**
* The contextualized embedding model to use
*/
model: '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).
*/
dimensions?: number;

/**
* Output encoding format for embeddings. base64_int8 returns base64-encoded signed
* int8 values. base64_binary returns base64-encoded packed binary (1 bit per
* dimension).
*/
encoding_format?: 'base64_int8' | 'base64_binary';
}

export declare namespace ContextualizedEmbeddings {
export {
type ContextualizedEmbeddingCreateResponse as ContextualizedEmbeddingCreateResponse,
type ContextualizedEmbeddingCreateParams as ContextualizedEmbeddingCreateParams,
};
}
76 changes: 76 additions & 0 deletions src/resources/embeddings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../core/resource';
import * as Shared from './shared';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';

export class Embeddings extends APIResource {
/**
* Generate embeddings for a list of texts. Use these embeddings for semantic
* search, clustering, and other machine learning applications.
*/
create(body: EmbeddingCreateParams, options?: RequestOptions): APIPromise<EmbeddingCreateResponse> {
return this._client.post('/v1/embeddings', { body, ...options });
}
}

/**
* Response body for embeddings request
*/
export interface EmbeddingCreateResponse {
/**
* List of embedding objects
*/
data?: Array<Shared.EmbeddingObject>;

/**
* The model used to generate embeddings
*/
model?: string;

/**
* The object type
*/
object?: string;

/**
* Token usage for the embeddings request
*/
usage?: Shared.EmbeddingsUsage;
}

export interface EmbeddingCreateParams {
/**
* 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.
*/
input: string | Array<string>;

/**
* The embedding model to use
*/
model: 'pplx-embed-v1-0.6b' | 'pplx-embed-v1-4b';

/**
* 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).
*/
dimensions?: number;

/**
* Output encoding format for embeddings. base64_int8 returns base64-encoded signed
* int8 values. base64_binary returns base64-encoded packed binary (1 bit per
* dimension).
*/
encoding_format?: 'base64_int8' | 'base64_binary';
}

export declare namespace Embeddings {
export {
type EmbeddingCreateResponse as EmbeddingCreateResponse,
type EmbeddingCreateParams as EmbeddingCreateParams,
};
}
6 changes: 6 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
export * from './shared';
export { Async } from './async/async';
export { Chat, type StreamChunk } from './chat/chat';
export {
ContextualizedEmbeddings,
type ContextualizedEmbeddingCreateResponse,
type ContextualizedEmbeddingCreateParams,
} from './contextualized-embeddings';
export { Embeddings, type EmbeddingCreateResponse, type EmbeddingCreateParams } from './embeddings';
export {
Responses,
type Annotation,
Expand Down
84 changes: 84 additions & 0 deletions src/resources/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,90 @@ export interface Choice {
finish_reason?: 'stop' | 'length' | null;
}

/**
* A single contextualized embedding result
*/
export interface ContextualizedEmbeddingObject {
/**
* List of embedding objects for chunks in this document
*/
data?: Array<EmbeddingObject>;

/**
* The index of the document this chunk belongs to
*/
index?: number;

/**
* The object type
*/
object?: string;
}

/**
* A single embedding result
*/
export interface EmbeddingObject {
/**
* 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).
*/
embedding?: string;

/**
* The index of the input text this embedding corresponds to
*/
index?: number;

/**
* The object type
*/
object?: string;
}

/**
* Token usage for the embeddings request
*/
export interface EmbeddingsUsage {
/**
* Cost breakdown for the request
*/
cost?: EmbeddingsUsage.Cost;

/**
* Number of tokens in the input texts
*/
prompt_tokens?: number;

/**
* Total number of tokens processed
*/
total_tokens?: number;
}

export namespace EmbeddingsUsage {
/**
* Cost breakdown for the request
*/
export interface Cost {
/**
* Currency of the cost values
*/
currency?: 'USD';

/**
* Cost for input tokens in USD
*/
input_cost?: number;

/**
* Total cost for the request in USD
*/
total_cost?: number;
}
}

/**
* Defines a JSON schema for structured output validation
*/
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.23.2'; // x-release-please-version
export const VERSION = '0.24.0'; // x-release-please-version
Loading