Skip to content
Open
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.25.0"
".": "0.26.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: 8
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-78325ecc9bdc8e9850866fcdd3be3d209b06f151059c774afc7e6005a1775f09.yml
openapi_spec_hash: 19a34c8ddd46f81dd0b0850af5ee42f3
config_hash: 620d4d190431b939dd17ac5d442918e6
configured_endpoints: 23
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/perplexity-ai%2Fperplexity-e7ac06ada1aa9e0a37a95c1aa5927efe563fc2683c7a144638fa8bd6f68012ac.yml
openapi_spec_hash: 3ced2367a3f063e4eddce3a3253a4087
config_hash: 12ef310e24ea5bae135eacbbe1a391ca
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.26.0 (2026-02-19)

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

### Features

* **api:** Add browser and sandbox API endpoints ([a35f39c](https://github.com/perplexityai/perplexity-node/commit/a35f39c37eddf661d131c9f07a7b4ea25d95ab5d))


### Chores

* **internal/client:** fix form-urlencoded requests ([36bfdb4](https://github.com/perplexityai/perplexity-node/commit/36bfdb4f151bc3d20e946f5658679edfe78d7f73))
* **internal:** remove mock server code ([4ea1e20](https://github.com/perplexityai/perplexity-node/commit/4ea1e202b3d5c6fa7bb993c5e4e62b690bdb48f6))
* update mock server docs ([73990f1](https://github.com/perplexityai/perplexity-node/commit/73990f1119a8240fa06d0985b06ecf7066cc1caf))

## 0.25.0 (2026-02-12)

Full Changelog: [v0.24.0...v0.25.0](https://github.com/perplexityai/perplexity-node/compare/v0.24.0...v0.25.0)
Expand Down
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ $ pnpm link -—global @perplexity-ai/perplexity_ai

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```sh
$ npx prism mock path/to/your/openapi.yml
```

```sh
$ yarn run test
```
Expand Down
65 changes: 65 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@
Types:

- <code><a href="./src/resources/shared.ts">APIPublicSearchResult</a></code>
- <code><a href="./src/resources/shared.ts">BrowserSessionResponse</a></code>
- <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">ExecuteCodeResponse</a></code>
- <code><a href="./src/resources/shared.ts">FileEntry</a></code>
- <code><a href="./src/resources/shared.ts">JsonSchemaFormat</a></code>
- <code><a href="./src/resources/shared.ts">ListFilesResponse</a></code>
- <code><a href="./src/resources/shared.ts">ListProcessesResponse</a></code>
- <code><a href="./src/resources/shared.ts">ModifiedFilesResponse</a></code>
- <code><a href="./src/resources/shared.ts">PauseSandboxResponse</a></code>
- <code><a href="./src/resources/shared.ts">ProcessInfo</a></code>
- <code><a href="./src/resources/shared.ts">ReadFileResponse</a></code>
- <code><a href="./src/resources/shared.ts">ResponseFormat</a></code>
- <code><a href="./src/resources/shared.ts">SandboxSessionResponse</a></code>
- <code><a href="./src/resources/shared.ts">SearchResult</a></code>
- <code><a href="./src/resources/shared.ts">UsageInfo</a></code>
- <code><a href="./src/resources/shared.ts">UserLocation</a></code>
- <code><a href="./src/resources/shared.ts">WebSearchOptions</a></code>
- <code><a href="./src/resources/shared.ts">WriteFileResponse</a></code>

# Chat

Expand Down Expand Up @@ -78,6 +89,60 @@ Methods:

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

# Browser

## Sessions

Methods:

- <code title="post /v1/browser/sessions">client.browser.sessions.<a href="./src/resources/browser/sessions.ts">create</a>() -> BrowserSessionResponse</code>
- <code title="delete /v1/browser/sessions/{session_id}">client.browser.sessions.<a href="./src/resources/browser/sessions.ts">delete</a>(sessionID) -> void</code>

# Sandbox

## Sessions

Methods:

- <code title="post /v1/sandbox/sessions">client.sandbox.sessions.<a href="./src/resources/sandbox/sessions/sessions.ts">create</a>({ ...params }) -> SandboxSessionResponse</code>
- <code title="delete /v1/sandbox/sessions/{session_id}">client.sandbox.sessions.<a href="./src/resources/sandbox/sessions/sessions.ts">delete</a>(sessionID) -> void</code>
- <code title="get /v1/sandbox/sessions/{session_id}">client.sandbox.sessions.<a href="./src/resources/sandbox/sessions/sessions.ts">get</a>(sessionID) -> SandboxSessionResponse</code>

### Execute

Methods:

- <code title="post /v1/sandbox/sessions/{session_id}/execute">client.sandbox.sessions.execute.<a href="./src/resources/sandbox/sessions/execute.ts">create</a>(sessionID, { ...params }) -> ExecuteCodeResponse</code>

### Pause

Methods:

- <code title="post /v1/sandbox/sessions/{session_id}/pause">client.sandbox.sessions.pause.<a href="./src/resources/sandbox/sessions/pause.ts">create</a>(sessionID) -> PauseSandboxResponse</code>

### Resume

Methods:

- <code title="post /v1/sandbox/sessions/{session_id}/resume">client.sandbox.sessions.resume.<a href="./src/resources/sandbox/sessions/resume.ts">create</a>(sessionID, { ...params }) -> SandboxSessionResponse</code>

### Files

Methods:

- <code title="get /v1/sandbox/sessions/{session_id}/files/list">client.sandbox.sessions.files.<a href="./src/resources/sandbox/sessions/files.ts">list</a>(sessionID, { ...params }) -> ListFilesResponse</code>
- <code title="get /v1/sandbox/sessions/{session_id}/files/modified">client.sandbox.sessions.files.<a href="./src/resources/sandbox/sessions/files.ts">modified</a>(sessionID) -> ModifiedFilesResponse</code>
- <code title="get /v1/sandbox/sessions/{session_id}/files">client.sandbox.sessions.files.<a href="./src/resources/sandbox/sessions/files.ts">read</a>(sessionID, { ...params }) -> ReadFileResponse</code>
- <code title="post /v1/sandbox/sessions/{session_id}/files">client.sandbox.sessions.files.<a href="./src/resources/sandbox/sessions/files.ts">write</a>(sessionID, { ...params }) -> WriteFileResponse</code>

### Processes

Methods:

- <code title="get /v1/sandbox/sessions/{session_id}/processes">client.sandbox.sessions.processes.<a href="./src/resources/sandbox/sessions/processes.ts">list</a>(sessionID) -> ListProcessesResponse</code>
- <code title="delete /v1/sandbox/sessions/{session_id}/processes/{pid}">client.sandbox.sessions.processes.<a href="./src/resources/sandbox/sessions/processes.ts">delete</a>(pid, { ...params }) -> void</code>
- <code title="get /v1/sandbox/sessions/{session_id}/processes/{pid}">client.sandbox.sessions.processes.<a href="./src/resources/sandbox/sessions/processes.ts">get</a>(pid, { ...params }) -> ProcessInfo</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.25.0",
"version": "0.26.0",
"description": "The official TypeScript library for the Perplexity API",
"author": "Perplexity <api@perplexity.ai>",
"types": "dist/index.d.ts",
Expand Down
41 changes: 0 additions & 41 deletions scripts/mock

This file was deleted.

46 changes: 0 additions & 46 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,7 @@ set -e

cd "$(dirname "$0")/.."

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
}

kill_server_on_port() {
pids=$(lsof -t -i tcp:"$1" || echo "")
if [ "$pids" != "" ]; then
kill "$pids"
echo "Stopped $pids."
fi
}

function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

# Start the dev server
./scripts/mock --daemon
fi

if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo
fi

echo "==> Running tests"
./node_modules/.bin/jest "$@"
29 changes: 29 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import {
} from './resources/responses';
import { Search, SearchCreateParams, SearchCreateResponse } from './resources/search';
import { Async } from './resources/async/async';
import { Browser } from './resources/browser/browser';
import { Chat, StreamChunk } from './resources/chat/chat';
import { Sandbox } from './resources/sandbox/sandbox';
import { type Fetch } from './internal/builtin-types';
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
Expand Down Expand Up @@ -722,6 +724,14 @@ export class Perplexity {
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
) {
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
} else if (
typeof body === 'object' &&
headers.values.get('content-type') === 'application/x-www-form-urlencoded'
) {
return {
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
body: this.stringifyQuery(body as Record<string, unknown>),
};
} else {
return this.#encoder({ body, headers });
}
Expand Down Expand Up @@ -751,6 +761,8 @@ export class Perplexity {
responses: API.Responses = new API.Responses(this);
embeddings: API.Embeddings = new API.Embeddings(this);
contextualizedEmbeddings: API.ContextualizedEmbeddings = new API.ContextualizedEmbeddings(this);
browser: API.Browser = new API.Browser(this);
sandbox: API.Sandbox = new API.Sandbox(this);
async: API.Async = new API.Async(this);
}

Expand All @@ -759,6 +771,8 @@ Perplexity.Search = Search;
Perplexity.Responses = Responses;
Perplexity.Embeddings = Embeddings;
Perplexity.ContextualizedEmbeddings = ContextualizedEmbeddings;
Perplexity.Browser = Browser;
Perplexity.Sandbox = Sandbox;
Perplexity.Async = Async;

export declare namespace Perplexity {
Expand Down Expand Up @@ -802,19 +816,34 @@ export declare namespace Perplexity {
type ContextualizedEmbeddingCreateParams as ContextualizedEmbeddingCreateParams,
};

export { Browser as Browser };

export { Sandbox as Sandbox };

export { Async as Async };

export type APIPublicSearchResult = API.APIPublicSearchResult;
export type BrowserSessionResponse = API.BrowserSessionResponse;
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 ExecuteCodeResponse = API.ExecuteCodeResponse;
export type FileEntry = API.FileEntry;
export type JsonSchemaFormat = API.JsonSchemaFormat;
export type ListFilesResponse = API.ListFilesResponse;
export type ListProcessesResponse = API.ListProcessesResponse;
export type ModifiedFilesResponse = API.ModifiedFilesResponse;
export type PauseSandboxResponse = API.PauseSandboxResponse;
export type ProcessInfo = API.ProcessInfo;
export type ReadFileResponse = API.ReadFileResponse;
export type ResponseFormat = API.ResponseFormat;
export type SandboxSessionResponse = API.SandboxSessionResponse;
export type SearchResult = API.SearchResult;
export type UsageInfo = API.UsageInfo;
export type UserLocation = API.UserLocation;
export type WebSearchOptions = API.WebSearchOptions;
export type WriteFileResponse = API.WriteFileResponse;
}
3 changes: 3 additions & 0 deletions src/resources/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './browser/index';
15 changes: 15 additions & 0 deletions src/resources/browser/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../core/resource';
import * as SessionsAPI from './sessions';
import { SessionCreateParams, Sessions } from './sessions';

export class Browser extends APIResource {
sessions: SessionsAPI.Sessions = new SessionsAPI.Sessions(this._client);
}

Browser.Sessions = Sessions;

export declare namespace Browser {
export { Sessions as Sessions, type SessionCreateParams as SessionCreateParams };
}
4 changes: 4 additions & 0 deletions src/resources/browser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Browser } from './browser';
export { Sessions, type SessionCreateParams } from './sessions';
36 changes: 36 additions & 0 deletions src/resources/browser/sessions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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 { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';

export class Sessions extends APIResource {
/**
* Create a new remote browser session for CDP-based automation.
*/
create(
body?: SessionCreateParams | null | undefined,
options?: RequestOptions,
): APIPromise<Shared.BrowserSessionResponse> {
return this._client.post('/v1/browser/sessions', { body, ...options });
}

/**
* Stop and clean up a remote browser session.
*/
delete(sessionID: string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/v1/browser/sessions/${sessionID}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
}

export interface SessionCreateParams {}

export declare namespace Sessions {
export { type SessionCreateParams as SessionCreateParams };
}
2 changes: 2 additions & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export * from './shared';
export { Async } from './async/async';
export { Browser } from './browser/browser';
export { Chat, type StreamChunk } from './chat/chat';
export {
ContextualizedEmbeddings,
Expand All @@ -26,4 +27,5 @@ export {
type ResponseCreateParamsNonStreaming,
type ResponseCreateParamsStreaming,
} from './responses';
export { Sandbox } from './sandbox/sandbox';
export { Search, type SearchCreateResponse, type SearchCreateParams } from './search';
Loading