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.21.0"
".": "0.22.0"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.22.0 (2026-01-24)

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

### Features

* **client:** integrate output_text automatically in responses.create() ([2b8b60a](https://github.com/perplexityai/perplexity-node/commit/2b8b60afe9e4cbb28dc6fbe66201c29d53bb60bc))


### Bug Fixes

* remove trailing whitespace in responses.ts ([9808062](https://github.com/perplexityai/perplexity-node/commit/9808062dc0acd80dd4b30280ac36ebc81402f5b7))

## 0.21.0 (2026-01-24)

Full Changelog: [v0.20.0...v0.21.0](https://github.com/perplexityai/perplexity-node/compare/v0.20.0...v0.21.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.21.0",
"version": "0.22.0",
"description": "The official TypeScript library for the Perplexity API",
"author": "Perplexity <api@perplexity.ai>",
"types": "dist/index.d.ts",
Expand Down
23 changes: 20 additions & 3 deletions src/resources/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as Shared from './shared';
import { APIPromise } from '../core/api-promise';
import { Stream } from '../core/streaming';
import { RequestOptions } from '../internal/request-options';
import { addOutputText } from '../lib/add-output-text';

export class Responses extends APIResource {
/**
Expand All @@ -28,9 +29,19 @@ export class Responses extends APIResource {
body: ResponseCreateParams,
options?: RequestOptions,
): APIPromise<ResponseCreateResponse> | APIPromise<Stream<ResponseStreamChunk>> {
return this._client.post('/v1/responses', { body, ...options, stream: body.stream ?? false }) as
| APIPromise<ResponseCreateResponse>
| APIPromise<Stream<ResponseStreamChunk>>;
const promise = this._client.post('/v1/responses', { body, ...options, stream: body.stream ?? false });

// For non-streaming responses, automatically add output_text property
if (!body.stream) {
return (promise as APIPromise<ResponseCreateResponse>)._thenUnwrap((rsp) => {
if ('object' in rsp && rsp.object === 'response') {
addOutputText(rsp as ResponseCreateResponse);
}
return rsp;
}) as APIPromise<ResponseCreateResponse>;
}

return promise as APIPromise<Stream<ResponseStreamChunk>>;
}
}

Expand Down Expand Up @@ -996,6 +1007,12 @@ export interface ResponseCreateResponse {
error?: ErrorInfo;

usage?: ResponsesUsage;

/**
* Convenience property that aggregates all `output_text` items from the `output` list.
* If no `output_text` content blocks exist, then an empty string is returned.
*/
output_text?: string;
}

export type ResponseCreateParams = ResponseCreateParamsNonStreaming | ResponseCreateParamsStreaming;
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.21.0'; // x-release-please-version
export const VERSION = '0.22.0'; // x-release-please-version