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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '20'
node-version: '24'

- name: Bootstrap
run: ./scripts/bootstrap
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '20'
node-version: '24'

- name: Bootstrap
run: ./scripts/bootstrap
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '20'
node-version: '24'

- name: Bootstrap
run: ./scripts/bootstrap
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: '20'
node-version: '24'

- name: Install dependencies
run: |
Expand Down
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.35.0"
".": "0.36.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: 13
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-f15eee99fec8579d1a543c4dfdc74f7633cc8e82004634be302f9c053cdc3934.yml
openapi_spec_hash: 5fe9895246acf0b07b2283b938a018fe
config_hash: 3f1487a29a16f85810ba4d77134da232
configured_endpoints: 14
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai/perplexity-0503b4a7abdf2cb4ad14af7b17bca179796f868729dfdfc8e09692e0dca99dda.yml
openapi_spec_hash: 629684ee997a5334c38080865371b0fa
config_hash: 25a3795c176e58c4127154760d603480
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.36.0 (2026-07-15)

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

### Features

* **api:** manual updates ([97833de](https://github.com/perplexityai/perplexity-node/commit/97833de3a6f175de815d2f18fa29acf801eeb89a))


### Bug Fixes

* **ci:** bump @arethetypeswrong/cli to ^0.18.0 and run CI workflows on Node 24 ([73acb76](https://github.com/perplexityai/perplexity-node/commit/73acb7668c131075b62c04d081d872c009c3e564))

## 0.35.0 (2026-07-09)

Full Changelog: [v0.34.0...v0.35.0](https://github.com/perplexityai/perplexity-node/compare/v0.34.0...v0.35.0)
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ Types:
- <code><a href="./src/resources/responses/responses.ts">ResponsesUsage</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseCreateResponse</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseRetrieveResponse</a></code>
- <code><a href="./src/resources/responses/responses.ts">ResponseCancelResponse</a></code>

Methods:

- <code title="post /v1/responses">client.responses.<a href="./src/resources/responses/responses.ts">create</a>({ ...params }) -> ResponseCreateResponse</code>
- <code title="get /v1/responses/{response_id}">client.responses.<a href="./src/resources/responses/responses.ts">retrieve</a>(responseID) -> ResponseRetrieveResponse</code>
- <code title="post /v1/responses/{response_id}/cancel">client.responses.<a href="./src/resources/responses/responses.ts">cancel</a>(responseID) -> ResponseCancelResponse</code>

## Files

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@perplexity-ai/perplexity_ai",
"version": "0.35.0",
"version": "0.36.0",
"description": "The official TypeScript library for the Perplexity API",
"author": "Perplexity <api@perplexity.ai>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -28,7 +28,7 @@
},
"dependencies": {},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.0",
"@arethetypeswrong/cli": "^0.18.0",
"@swc/core": "^1.3.102",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.4.0",
Expand Down
2 changes: 2 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
FunctionTool,
InputItem,
OutputItem,
ResponseCancelResponse,
ResponseCreateParams,
ResponseCreateParamsNonStreaming,
ResponseCreateParamsStreaming,
Expand Down Expand Up @@ -813,6 +814,7 @@ export declare namespace Perplexity {
type ResponsesUsage as ResponsesUsage,
type ResponseCreateResponse as ResponseCreateResponse,
type ResponseRetrieveResponse as ResponseRetrieveResponse,
type ResponseCancelResponse as ResponseCancelResponse,
type ResponseCreateParams as ResponseCreateParams,
type ResponseCreateParamsNonStreaming as ResponseCreateParamsNonStreaming,
type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming,
Expand Down
7 changes: 7 additions & 0 deletions src/resources/async/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ export namespace CompletionCreateParams {
| Request.ResponseFormatRegex
| null;

/**
* Optional locale tag used for response formatting conventions. Locale-style
* values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
* form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.
*/
response_formatting_locale?: string | null;

response_metadata?: { [key: string]: unknown } | null;

return_images?: boolean | null;
Expand Down
7 changes: 7 additions & 0 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ export interface CompletionCreateParamsBase {
| CompletionCreateParams.ResponseFormatRegex
| null;

/**
* Optional locale tag used for response formatting conventions. Locale-style
* values such as `es_mx`, `EN-us`, and `zh-TW` are normalized to the canonical
* form (`es-MX`, `en-US`, `zh-TW`). Invalid values are ignored.
*/
response_formatting_locale?: string | null;

response_metadata?: { [key: string]: unknown } | null;

return_images?: boolean | null;
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
type ResponsesUsage,
type ResponseCreateResponse,
type ResponseRetrieveResponse,
type ResponseCancelResponse,
type ResponseCreateParams,
type ResponseCreateParamsNonStreaming,
type ResponseCreateParamsStreaming,
Expand Down
1 change: 1 addition & 0 deletions src/resources/responses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
type ResponsesUsage,
type ResponseCreateResponse,
type ResponseRetrieveResponse,
type ResponseCancelResponse,
type ResponseCreateParams,
type ResponseCreateParamsNonStreaming,
type ResponseCreateParamsStreaming,
Expand Down
92 changes: 92 additions & 0 deletions src/resources/responses/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ export class Responses extends APIResource {
retrieve(responseID: string, options?: RequestOptions): APIPromise<ResponseRetrieveResponse> {
return this._client.get(path`/v1/responses/${responseID}`, options);
}

/**
* Request cancellation of a response. Acts on durable state, so it works for
* background responses that outlive the client connection as well as durably
* routed foreground responses. The cancel is asynchronous: a 200 acknowledges the
* request (status `cancelling`) and the run stops shortly after. Poll the retrieve
* endpoint for the terminal status. Cancelling a run that is already terminal
* returns 400. Ownership is enforced server side; an unknown id, or a response
* belonging to a different account, returns 404.
*/
cancel(responseID: string, options?: RequestOptions): APIPromise<ResponseCancelResponse> {
return this._client.post(path`/v1/responses/${responseID}/cancel`, options);
}
}

/**
Expand Down Expand Up @@ -474,6 +487,19 @@ export namespace ResponseStreamChunk {

error?: ResponsesAPI.ErrorInfo;

/**
* ID of the previous response in the chain, when the response was created with
* previous_response_id.
*/
previous_response_id?: string | null;

/**
* Whether the response is stored and visible to later retrieve calls. A response
* created with store=false can still be used as a previous_response_id
* continuation source.
*/
store?: boolean;

usage?: ResponsesAPI.ResponsesUsage;
}
}
Expand Down Expand Up @@ -529,6 +555,19 @@ export namespace ResponseStreamChunk {

error?: ResponsesAPI.ErrorInfo;

/**
* ID of the previous response in the chain, when the response was created with
* previous_response_id.
*/
previous_response_id?: string | null;

/**
* Whether the response is stored and visible to later retrieve calls. A response
* created with store=false can still be used as a previous_response_id
* continuation source.
*/
store?: boolean;

usage?: ResponsesAPI.ResponsesUsage;
}
}
Expand Down Expand Up @@ -583,6 +622,19 @@ export namespace ResponseStreamChunk {

error?: ResponsesAPI.ErrorInfo;

/**
* ID of the previous response in the chain, when the response was created with
* previous_response_id.
*/
previous_response_id?: string | null;

/**
* Whether the response is stored and visible to later retrieve calls. A response
* created with store=false can still be used as a previous_response_id
* continuation source.
*/
store?: boolean;

usage?: ResponsesAPI.ResponsesUsage;
}
}
Expand Down Expand Up @@ -1162,6 +1214,19 @@ export interface ResponseCreateResponse {

error?: ErrorInfo;

/**
* ID of the previous response in the chain, when the response was created with
* previous_response_id.
*/
previous_response_id?: string | null;

/**
* Whether the response is stored and visible to later retrieve calls. A response
* created with store=false can still be used as a previous_response_id
* continuation source.
*/
store?: boolean;

usage?: ResponsesUsage;

/**
Expand Down Expand Up @@ -1200,6 +1265,19 @@ export interface ResponseRetrieveResponse {

error?: ErrorInfo;

/**
* ID of the previous response in the chain, when the response was created with
* previous_response_id.
*/
previous_response_id?: string | null;

/**
* Whether the response is stored and visible to later retrieve calls. A response
* created with store=false can still be used as a previous_response_id
* continuation source.
*/
store?: boolean;

usage?: ResponsesUsage;

/**
Expand All @@ -1209,6 +1287,19 @@ export interface ResponseRetrieveResponse {
output_text?: string;
}

export interface ResponseCancelResponse {
/**
* The response id (resp\_...).
*/
response_id: string;

/**
* Always `cancelling`: the cancel was accepted and the run stops asynchronously.
* An already terminal run returns 400 instead, so no terminal status appears here.
*/
status: 'cancelling';
}

export type ResponseCreateParams = ResponseCreateParamsNonStreaming | ResponseCreateParamsStreaming;

export interface ResponseCreateParamsBase {
Expand Down Expand Up @@ -1489,6 +1580,7 @@ export declare namespace Responses {
type ResponsesUsage as ResponsesUsage,
type ResponseCreateResponse as ResponseCreateResponse,
type ResponseRetrieveResponse as ResponseRetrieveResponse,
type ResponseCancelResponse as ResponseCancelResponse,
type ResponseCreateParams as ResponseCreateParams,
type ResponseCreateParamsNonStreaming as ResponseCreateParamsNonStreaming,
type ResponseCreateParamsStreaming as ResponseCreateParamsStreaming,
Expand Down
4 changes: 4 additions & 0 deletions src/resources/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ export namespace UsageInfo {

reasoning_tokens_cost?: number | null;

/**
* Flat request cost for the chat completion. Present on completed (terminal)
* responses and omitted from the zero cost skeleton on interim streaming chunks.
*/
request_cost?: number | null;

search_queries_cost?: number | null;
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.35.0'; // x-release-please-version
export const VERSION = '0.36.0'; // x-release-please-version
1 change: 1 addition & 0 deletions tests/api-resources/async/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('resource completions', () => {
ranking_model: 'ranking_model',
reasoning_effort: 'minimal',
response_format: { type: 'text' },
response_formatting_locale: 'response_formatting_locale',
response_metadata: { foo: 'bar' },
return_images: true,
return_related_questions: true,
Expand Down
1 change: 1 addition & 0 deletions tests/api-resources/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('resource completions', () => {
ranking_model: 'ranking_model',
reasoning_effort: 'minimal',
response_format: { type: 'text' },
response_formatting_locale: 'response_formatting_locale',
response_metadata: { foo: 'bar' },
return_images: true,
return_related_questions: true,
Expand Down
12 changes: 12 additions & 0 deletions tests/api-resources/responses/responses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,16 @@ describe('resource responses', () => {
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

// Mock server tests are disabled
test.skip('cancel', async () => {
const responsePromise = client.responses.cancel('response_id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});
});
Loading