diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06577d4..d5effb3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 567dfb1..c95217b 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -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: | diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3a39fd8..93c546c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.35.0" + ".": "0.36.0" } diff --git a/.stats.yml b/.stats.yml index 8659912..63a07a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 23d58bb..e271ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/api.md b/api.md index a246159..ced375e 100644 --- a/api.md +++ b/api.md @@ -57,11 +57,13 @@ Types: - ResponsesUsage - ResponseCreateResponse - ResponseRetrieveResponse +- ResponseCancelResponse Methods: - client.responses.create({ ...params }) -> ResponseCreateResponse - client.responses.retrieve(responseID) -> ResponseRetrieveResponse +- client.responses.cancel(responseID) -> ResponseCancelResponse ## Files diff --git a/package.json b/package.json index 1a3a87a..20056ed 100644 --- a/package.json +++ b/package.json @@ -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 ", "types": "dist/index.d.ts", @@ -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", diff --git a/src/client.ts b/src/client.ts index 432ba82..5b163cb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -35,6 +35,7 @@ import { FunctionTool, InputItem, OutputItem, + ResponseCancelResponse, ResponseCreateParams, ResponseCreateParamsNonStreaming, ResponseCreateParamsStreaming, @@ -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, diff --git a/src/resources/async/chat/completions.ts b/src/resources/async/chat/completions.ts index 787240a..0a51d13 100644 --- a/src/resources/async/chat/completions.ts +++ b/src/resources/async/chat/completions.ts @@ -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; diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts index 225d8fd..a867233 100644 --- a/src/resources/chat/completions.ts +++ b/src/resources/chat/completions.ts @@ -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; diff --git a/src/resources/index.ts b/src/resources/index.ts index 71fdeb5..57ce5a4 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -26,6 +26,7 @@ export { type ResponsesUsage, type ResponseCreateResponse, type ResponseRetrieveResponse, + type ResponseCancelResponse, type ResponseCreateParams, type ResponseCreateParamsNonStreaming, type ResponseCreateParamsStreaming, diff --git a/src/resources/responses/index.ts b/src/resources/responses/index.ts index 33fd829..2b6f4d0 100644 --- a/src/resources/responses/index.ts +++ b/src/resources/responses/index.ts @@ -17,6 +17,7 @@ export { type ResponsesUsage, type ResponseCreateResponse, type ResponseRetrieveResponse, + type ResponseCancelResponse, type ResponseCreateParams, type ResponseCreateParamsNonStreaming, type ResponseCreateParamsStreaming, diff --git a/src/resources/responses/responses.ts b/src/resources/responses/responses.ts index 95a7899..bfe9a05 100644 --- a/src/resources/responses/responses.ts +++ b/src/resources/responses/responses.ts @@ -55,6 +55,19 @@ export class Responses extends APIResource { retrieve(responseID: string, options?: RequestOptions): APIPromise { 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 { + return this._client.post(path`/v1/responses/${responseID}/cancel`, options); + } } /** @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; /** @@ -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; /** @@ -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 { @@ -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, diff --git a/src/resources/shared.ts b/src/resources/shared.ts index ee49414..906657d 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -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; diff --git a/src/version.ts b/src/version.ts index 3f1d432..018dddd 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.35.0'; // x-release-please-version +export const VERSION = '0.36.0'; // x-release-please-version diff --git a/tests/api-resources/async/chat/completions.test.ts b/tests/api-resources/async/chat/completions.test.ts index 429241a..c92b43c 100644 --- a/tests/api-resources/async/chat/completions.test.ts +++ b/tests/api-resources/async/chat/completions.test.ts @@ -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, diff --git a/tests/api-resources/chat/completions.test.ts b/tests/api-resources/chat/completions.test.ts index aede87d..9502498 100644 --- a/tests/api-resources/chat/completions.test.ts +++ b/tests/api-resources/chat/completions.test.ts @@ -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, diff --git a/tests/api-resources/responses/responses.test.ts b/tests/api-resources/responses/responses.test.ts index a0f4ea4..3b62c26 100644 --- a/tests/api-resources/responses/responses.test.ts +++ b/tests/api-resources/responses/responses.test.ts @@ -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); + }); }); diff --git a/yarn.lock b/yarn.lock index 38236e6..443cc05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,12 +12,12 @@ resolved "https://registry.yarnpkg.com/@andrewbranch/untar.js/-/untar.js-1.0.3.tgz#ba9494f85eb83017c5c855763969caf1d0adea00" integrity sha512-Jh15/qVmrLGhkKJBdXlK1+9tY4lZruYjsgkDFj08ZmDiWVBLJcqkok7Z0/R0In+i1rScBpJlSvrTS2Lm41Pbnw== -"@arethetypeswrong/cli@^0.17.0": - version "0.17.0" - resolved "https://registry.yarnpkg.com/@arethetypeswrong/cli/-/cli-0.17.0.tgz#f97f10926b3f9f9eb5117550242d2e06c25cadac" - integrity sha512-xSMW7bfzVWpYw5JFgZqBXqr6PdR0/REmn3DkxCES5N0JTcB0CVgbIynJCvKBFmXaPc3hzmmTrb7+yPDRoOSZdA== +"@arethetypeswrong/cli@^0.18.0": + version "0.18.4" + resolved "https://registry.yarnpkg.com/@arethetypeswrong/cli/-/cli-0.18.4.tgz#c31f54f3b0d0e0f3256ab3edb6530beeb5e64b4b" + integrity sha512-kNWo6LTzGAuLYPpJ7Sgo63whSUeeSuKMlYx6IBgzs4ONEG807gW4hSSENvpeCHzO2H2wIzG5EFl0OKBbqGBAyA== dependencies: - "@arethetypeswrong/core" "0.17.0" + "@arethetypeswrong/core" "0.18.4" chalk "^4.1.2" cli-table3 "^0.6.3" commander "^10.0.1" @@ -25,15 +25,16 @@ marked-terminal "^7.1.0" semver "^7.5.4" -"@arethetypeswrong/core@0.17.0": - version "0.17.0" - resolved "https://registry.yarnpkg.com/@arethetypeswrong/core/-/core-0.17.0.tgz#abb3b5f425056d37193644c2a2de4aecf866b76b" - integrity sha512-FHyhFizXNetigTVsIhqXKGYLpazPS5YNojEPpZEUcBPt9wVvoEbNIvG+hybuBR+pjlRcbyuqhukHZm1fr+bDgA== +"@arethetypeswrong/core@0.18.4": + version "0.18.4" + resolved "https://registry.yarnpkg.com/@arethetypeswrong/core/-/core-0.18.4.tgz#24edea3d651dea7d32bf6f1cc9ee9a00db39de49" + integrity sha512-M5F0ePyN6h2Z6XxRiyIPqjGbltotXLjR0CKA0uKspsDu0QmgTNYvRb4RSQPMUs2ZXZHCCYpbaZbFbYOXLxCjUA== dependencies: "@andrewbranch/untar.js" "^1.0.3" + "@loaderkit/resolve" "^1.0.2" cjs-module-lexer "^1.2.3" - fflate "^0.8.2" - lru-cache "^10.4.3" + fflate "^0.8.3" + lru-cache "^11.0.1" semver "^7.5.4" typescript "5.6.1-rc" validate-npm-package-name "^5.0.0" @@ -306,6 +307,11 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@braidai/lang@^1.0.0": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@braidai/lang/-/lang-1.1.2.tgz#65bc2bc1db6d00e153b95ac7006f4573e289e9be" + integrity sha512-qBcknbBufNHlui137Hft8xauQMTZDKdophmLFv05r2eNmdIv/MlPuP4TdUknHG68UdWLgVZwgxVe735HzJNIwA== + "@colors/colors@1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" @@ -688,6 +694,13 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@loaderkit/resolve@^1.0.2": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@loaderkit/resolve/-/resolve-1.0.6.tgz#8d45341e688faecc25b3ae919c0f45d94c4e26c9" + integrity sha512-G8FdIoF5CypfwmD9rl8BXod5HDn8JqB0CCNBXDTaRZ+yRYhARrrSToX1zg1zy9jX3zLqigsELwhT4gNtkdQAUg== + dependencies: + "@braidai/lang" "^1.0.0" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -1696,10 +1709,10 @@ fb-watchman@^2.0.0: dependencies: bser "2.1.1" -fflate@^0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.8.2.tgz#fc8631f5347812ad6028bbe4a2308b2792aa1dea" - integrity sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A== +fflate@^0.8.3: + version "0.8.3" + resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.8.3.tgz#bc27d8eb30343d4d512abb03480202ce65d825fc" + integrity sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA== file-entry-cache@^8.0.0: version "8.0.0" @@ -2490,10 +2503,10 @@ lodash.merge@^4.6.2: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lru-cache@^10.4.3: - version "10.4.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" - integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== +lru-cache@^11.0.1: + version "11.5.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-11.5.2.tgz#00e16665c90c620fba14a3c368732a976493f760" + integrity sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g== lru-cache@^5.1.1: version "5.1.1"