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.8.0"
".": "0.9.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-aba0c21c569842e93e17b69cae9cee58d389fce9c2482f4d251fd8727db05679.yml
openapi_spec_hash: 3d01b1c1425f7d43a8acf8b99bb9b321
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-51a3b755ae8040a6baeff490b3226a94c02a71aca6c4754dd365d7d0de8e399d.yml
openapi_spec_hash: 03d28237de381a5b914ef738b3587bb5
config_hash: 0be7520657a7a0fb6b5a839e716fe30c
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.9.0 (2025-10-08)

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

### Features

* **api:** manual updates ([d17785c](https://github.com/perplexityai/perplexity-node/commit/d17785c3ec2ec4bf22d0719da119f13db8c8c0fd))


### Chores

* **internal:** use npm pack for build uploads ([b2d7e82](https://github.com/perplexityai/perplexity-node/commit/b2d7e82ea8ac19c91e8b675230ffc81c73915f21))
* **jsdoc:** fix [@link](https://github.com/link) annotations to refer only to parts of the package‘s public interface ([657927d](https://github.com/perplexityai/perplexity-node/commit/657927d9f2a0b50f8fd93ec68ee7f2b1c35e7845))

## 0.8.0 (2025-10-02)

Full Changelog: [v0.7.1...v0.8.0](https://github.com/perplexityai/perplexity-node/compare/v0.7.1...v0.8.0)
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.8.0",
"version": "0.9.0",
"description": "The official TypeScript library for the Perplexity API",
"author": "Perplexity <>",
"types": "dist/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ if [[ "$SIGNED_URL" == "null" ]]; then
exit 1
fi

UPLOAD_RESPONSE=$(tar "${BASE_PATH:+-C$BASE_PATH}" -cz "${ARTIFACT_PATH:-dist}" | curl -v -X PUT \
TARBALL=$(cd dist && npm pack --silent)

UPLOAD_RESPONSE=$(curl -v -X PUT \
-H "Content-Type: application/gzip" \
--data-binary @- "$SIGNED_URL" 2>&1)
--data-binary "@dist/$TARBALL" "$SIGNED_URL" 2>&1)

if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/to-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export type ToFileInput =

/**
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
* @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s
* @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
* @param {Object=} options additional properties
* @param {string=} options.type the MIME type of the content
Expand Down
28 changes: 21 additions & 7 deletions src/resources/async/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@ import { path } from '../../../internal/utils/path';

export class Completions extends APIResource {
/**
* FastAPI wrapper around async chat completions
*
* This endpoint creates an asynchronous chat completion job and returns a job ID
* that can be used to poll for results.
* Submit an asynchronous chat completion request.
*/
create(body: CompletionCreateParams, options?: RequestOptions): APIPromise<CompletionCreateResponse> {
return this._client.post('/async/chat/completions', { body, ...options });
}

/**
* list all async chat completion requests for a given user.
* Retrieve a list of all asynchronous chat completion requests for a given user.
*/
list(options?: RequestOptions): APIPromise<CompletionListResponse> {
return this._client.get('/async/chat/completions', options);
}

/**
* get the response for a given async chat completion request.
* Retrieve the response for a given asynchronous chat completion request.
*/
get(
apiRequest: string,
Expand All @@ -37,6 +34,7 @@ export class Completions extends APIResource {
const {
'x-client-env': xClientEnv,
'x-client-name': xClientName,
'x-created-at-epoch-seconds': xCreatedAtEpochSeconds,
'x-request-time': xRequestTime,
'x-usage-tier': xUsageTier,
'x-user-id': xUserID,
Expand All @@ -49,6 +47,9 @@ export class Completions extends APIResource {
{
...(xClientEnv != null ? { 'x-client-env': xClientEnv } : undefined),
...(xClientName != null ? { 'x-client-name': xClientName } : undefined),
...(xCreatedAtEpochSeconds != null ?
{ 'x-created-at-epoch-seconds': xCreatedAtEpochSeconds }
: undefined),
...(xRequestTime != null ? { 'x-request-time': xRequestTime } : undefined),
...(xUsageTier != null ? { 'x-usage-tier': xUsageTier } : undefined),
...(xUserID != null ? { 'x-user-id': xUserID } : undefined),
Expand Down Expand Up @@ -176,6 +177,8 @@ export namespace CompletionCreateParams {

image_format_filter?: Array<string> | null;

language_preference?: string | null;

last_updated_after_filter?: string | null;

last_updated_before_filter?: string | null;
Expand Down Expand Up @@ -234,8 +237,12 @@ export namespace CompletionCreateParams {

stream?: boolean | null;

stream_mode?: 'full' | 'concise';

temperature?: number | null;

thread_id?: string | null;

tool_choice?: 'none' | 'auto' | 'required' | null;

tools?: Array<Request.Tool> | null;
Expand All @@ -250,6 +257,8 @@ export namespace CompletionCreateParams {

updated_before_timestamp?: number | null;

use_threads?: boolean | null;

web_search_options?: Request.WebSearchOptions;
}

Expand Down Expand Up @@ -335,7 +344,7 @@ export namespace CompletionCreateParams {

search_context_size?: 'low' | 'medium' | 'high';

search_type?: 'fast' | 'pro' | 'auto';
search_type?: 'fast' | 'pro' | 'auto' | null;

user_location?: WebSearchOptions.UserLocation | null;
}
Expand Down Expand Up @@ -372,6 +381,11 @@ export interface CompletionGetParams {
*/
'x-client-name'?: string;

/**
* Header param:
*/
'x-created-at-epoch-seconds'?: string;

/**
* Header param:
*/
Expand Down
4 changes: 2 additions & 2 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export interface StreamChunk {

model: string;

usage: Shared.UsageInfo;

citations?: Array<string> | null;

object?: string;
Expand All @@ -34,6 +32,8 @@ export interface StreamChunk {
status?: 'PENDING' | 'COMPLETED' | null;

type?: 'message' | 'info' | 'end_of_stream' | null;

usage?: Shared.UsageInfo | null;
}

Chat.Completions = Completions;
Expand Down
12 changes: 10 additions & 2 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { RequestOptions } from '../../internal/request-options';

export class Completions extends APIResource {
/**
* FastAPI wrapper around chat completions
* Generate a chat completion response for the given conversation.
*/
create(body: CompletionCreateParamsNonStreaming, options?: RequestOptions): APIPromise<ChatAPI.StreamChunk>;
create(
Expand Down Expand Up @@ -70,6 +70,8 @@ export interface CompletionCreateParamsBase {

image_format_filter?: Array<string> | null;

language_preference?: string | null;

last_updated_after_filter?: string | null;

last_updated_before_filter?: string | null;
Expand Down Expand Up @@ -128,8 +130,12 @@ export interface CompletionCreateParamsBase {

stream?: boolean | null;

stream_mode?: 'full' | 'concise';

temperature?: number | null;

thread_id?: string | null;

tool_choice?: 'none' | 'auto' | 'required' | null;

tools?: Array<CompletionCreateParams.Tool> | null;
Expand All @@ -144,6 +150,8 @@ export interface CompletionCreateParamsBase {

updated_before_timestamp?: number | null;

use_threads?: boolean | null;

web_search_options?: CompletionCreateParams.WebSearchOptions;
}

Expand Down Expand Up @@ -229,7 +237,7 @@ export namespace CompletionCreateParams {

search_context_size?: 'low' | 'medium' | 'high';

search_type?: 'fast' | 'pro' | 'auto';
search_type?: 'fast' | 'pro' | 'auto' | null;

user_location?: WebSearchOptions.UserLocation | null;
}
Expand Down
6 changes: 4 additions & 2 deletions src/resources/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { RequestOptions } from '../internal/request-options';

export class Search extends APIResource {
/**
* Search
* Search the web and retrieve relevant web page contents.
*/
create(body: SearchCreateParams, options?: RequestOptions): APIPromise<SearchCreateResponse> {
return this._client.post('/search', { body, ...options });
Expand All @@ -17,6 +17,8 @@ export interface SearchCreateResponse {
id: string;

results: Array<SearchCreateResponse.Result>;

server_time?: string | null;
}

export namespace SearchCreateResponse {
Expand All @@ -36,7 +38,7 @@ export namespace SearchCreateResponse {
export interface SearchCreateParams {
query: string | Array<string>;

country?: string | null;
display_server_time?: boolean;

max_results?: number;

Expand Down
2 changes: 2 additions & 0 deletions src/resources/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface APIPublicSearchResult {
last_updated?: string | null;

snippet?: string;

source?: 'web' | 'attachment';
}

export interface ChatMessageInput {
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.8.0'; // x-release-please-version
export const VERSION = '0.9.0'; // x-release-please-version
7 changes: 7 additions & 0 deletions tests/api-resources/async/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('resource completions', () => {
date: 'date',
last_updated: 'last_updated',
snippet: 'snippet',
source: 'web',
},
],
},
Expand All @@ -59,6 +60,7 @@ describe('resource completions', () => {
date: 'date',
last_updated: 'last_updated',
snippet: 'snippet',
source: 'web',
},
],
},
Expand Down Expand Up @@ -87,6 +89,7 @@ describe('resource completions', () => {
has_image_url: true,
image_domain_filter: ['string'],
image_format_filter: ['string'],
language_preference: 'language_preference',
last_updated_after_filter: 'last_updated_after_filter',
last_updated_before_filter: 'last_updated_before_filter',
latitude: 0,
Expand Down Expand Up @@ -114,7 +117,9 @@ describe('resource completions', () => {
search_tenant: 'search_tenant',
stop: 'string',
stream: true,
stream_mode: 'full',
temperature: 0,
thread_id: 'thread_id',
tool_choice: 'none',
tools: [
{
Expand All @@ -137,6 +142,7 @@ describe('resource completions', () => {
top_p: 0,
updated_after_timestamp: 0,
updated_before_timestamp: 0,
use_threads: true,
web_search_options: {
image_results_enhanced_relevance: true,
search_context_size: 'low',
Expand Down Expand Up @@ -182,6 +188,7 @@ describe('resource completions', () => {
local_mode: true,
'x-client-env': 'x-client-env',
'x-client-name': 'x-client-name',
'x-created-at-epoch-seconds': 'x-created-at-epoch-seconds',
'x-request-time': 'x-request-time',
'x-usage-tier': 'x-usage-tier',
'x-user-id': 'x-user-id',
Expand Down
6 changes: 6 additions & 0 deletions tests/api-resources/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('resource completions', () => {
date: 'date',
last_updated: 'last_updated',
snippet: 'snippet',
source: 'web',
},
],
},
Expand All @@ -59,6 +60,7 @@ describe('resource completions', () => {
date: 'date',
last_updated: 'last_updated',
snippet: 'snippet',
source: 'web',
},
],
},
Expand Down Expand Up @@ -87,6 +89,7 @@ describe('resource completions', () => {
has_image_url: true,
image_domain_filter: ['string'],
image_format_filter: ['string'],
language_preference: 'language_preference',
last_updated_after_filter: 'last_updated_after_filter',
last_updated_before_filter: 'last_updated_before_filter',
latitude: 0,
Expand Down Expand Up @@ -114,7 +117,9 @@ describe('resource completions', () => {
search_tenant: 'search_tenant',
stop: 'string',
stream: false,
stream_mode: 'full',
temperature: 0,
thread_id: 'thread_id',
tool_choice: 'none',
tools: [
{
Expand All @@ -137,6 +142,7 @@ describe('resource completions', () => {
top_p: 0,
updated_after_timestamp: 0,
updated_before_timestamp: 0,
use_threads: true,
web_search_options: {
image_results_enhanced_relevance: true,
search_context_size: 'low',
Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('resource search', () => {
test.skip('create: required and optional params', async () => {
const response = await client.search.create({
query: 'string',
country: 'country',
display_server_time: true,
max_results: 0,
max_tokens: 0,
max_tokens_per_page: 0,
Expand Down