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

## 0.18.4 (2026-01-13)

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

### Chores

* break long lines in snippets into multiline ([659cf62](https://github.com/perplexityai/perplexity-node/commit/659cf62198caebd226509583cec3e0adb729c23d))
* fix typo in descriptions ([9b3231f](https://github.com/perplexityai/perplexity-node/commit/9b3231fda472fca273e7777ae6204f8ca8260b38))

## 0.18.3 (2026-01-05)

Full Changelog: [v0.18.2...v0.18.3](https://github.com/perplexityai/perplexity-node/compare/v0.18.2...v0.18.3)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ const search = await client.search

// Chat completions error handling
const streamChunk = await client.chat.completions
.create({ messages: [{ role: 'user', content: 'What is the capital of France?' }], model: 'sonar' })
.create({
messages: [{ role: 'user', content: 'What is the capital of France?' }],
model: 'sonar',
})
.catch(async (err) => {
if (err instanceof Perplexity.APIError) {
console.log(err.status); // 400
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.18.3",
"version": "0.18.4",
"description": "The official TypeScript library for the Perplexity API",
"author": "Perplexity <api@perplexity.ai>",
"types": "dist/index.d.ts",
Expand Down
14 changes: 7 additions & 7 deletions src/resources/async/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,37 +363,37 @@ export namespace CompletionCreateParams {

export interface CompletionGetParams {
/**
* Query param:
* Query param
*/
local_mode?: boolean;

/**
* Header param:
* Header param
*/
'x-client-env'?: string;

/**
* Header param:
* Header param
*/
'x-client-name'?: string;

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

/**
* Header param:
* Header param
*/
'x-request-time'?: string;

/**
* Header param:
* Header param
*/
'x-usage-tier'?: string;

/**
* Header param:
* Header param
*/
'x-user-id'?: string;
}
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.18.3'; // x-release-please-version
export const VERSION = '0.18.4'; // x-release-please-version
16 changes: 14 additions & 2 deletions tests/api-resources/async/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ describe('resource completions', () => {
},
],
tool_call_id: 'tool_call_id',
tool_calls: [{ id: 'id', function: { arguments: 'arguments', name: 'name' }, type: 'function' }],
tool_calls: [
{
id: 'id',
function: { arguments: 'arguments', name: 'name' },
type: 'function',
},
],
},
],
model: 'model',
Expand Down Expand Up @@ -142,7 +148,13 @@ describe('resource completions', () => {
image_results_enhanced_relevance: true,
search_context_size: 'low',
search_type: 'fast',
user_location: { city: 'city', country: 'country', latitude: 0, longitude: 0, region: 'region' },
user_location: {
city: 'city',
country: 'country',
latitude: 0,
longitude: 0,
region: 'region',
},
},
},
idempotency_key: 'idempotency_key',
Expand Down
16 changes: 14 additions & 2 deletions tests/api-resources/chat/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ describe('resource completions', () => {
},
],
tool_call_id: 'tool_call_id',
tool_calls: [{ id: 'id', function: { arguments: 'arguments', name: 'name' }, type: 'function' }],
tool_calls: [
{
id: 'id',
function: { arguments: 'arguments', name: 'name' },
type: 'function',
},
],
},
],
model: 'model',
Expand Down Expand Up @@ -142,7 +148,13 @@ describe('resource completions', () => {
image_results_enhanced_relevance: true,
search_context_size: 'low',
search_type: 'fast',
user_location: { city: 'city', country: 'country', latitude: 0, longitude: 0, region: 'region' },
user_location: {
city: 'city',
country: 'country',
latitude: 0,
longitude: 0,
region: 'region',
},
},
});
});
Expand Down
48 changes: 40 additions & 8 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ describe('instantiate client', () => {
error: jest.fn(),
};

const client = new Perplexity({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' });
const client = new Perplexity({
logger: logger,
logLevel: 'debug',
apiKey: 'My API Key',
});

await forceAPIResponseForClient(client);
expect(debugMock).toHaveBeenCalled();
Expand All @@ -107,7 +111,11 @@ describe('instantiate client', () => {
error: jest.fn(),
};

const client = new Perplexity({ logger: logger, logLevel: 'info', apiKey: 'My API Key' });
const client = new Perplexity({
logger: logger,
logLevel: 'info',
apiKey: 'My API Key',
});

await forceAPIResponseForClient(client);
expect(debugMock).not.toHaveBeenCalled();
Expand Down Expand Up @@ -157,7 +165,11 @@ describe('instantiate client', () => {
};

process.env['PERPLEXITY_LOG'] = 'debug';
const client = new Perplexity({ logger: logger, logLevel: 'off', apiKey: 'My API Key' });
const client = new Perplexity({
logger: logger,
logLevel: 'off',
apiKey: 'My API Key',
});

await forceAPIResponseForClient(client);
expect(debugMock).not.toHaveBeenCalled();
Expand All @@ -173,7 +185,11 @@ describe('instantiate client', () => {
};

process.env['PERPLEXITY_LOG'] = 'not a log level';
const client = new Perplexity({ logger: logger, logLevel: 'debug', apiKey: 'My API Key' });
const client = new Perplexity({
logger: logger,
logLevel: 'debug',
apiKey: 'My API Key',
});
expect(client.logLevel).toBe('debug');
expect(warnMock).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -543,7 +559,11 @@ describe('retries', () => {
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};

const client = new Perplexity({ apiKey: 'My API Key', timeout: 10, fetch: testFetch });
const client = new Perplexity({
apiKey: 'My API Key',
timeout: 10,
fetch: testFetch,
});

expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
expect(count).toEqual(2);
Expand Down Expand Up @@ -573,7 +593,11 @@ describe('retries', () => {
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};

const client = new Perplexity({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
const client = new Perplexity({
apiKey: 'My API Key',
fetch: testFetch,
maxRetries: 4,
});

expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });

Expand All @@ -597,7 +621,11 @@ describe('retries', () => {
capturedRequest = init;
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};
const client = new Perplexity({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
const client = new Perplexity({
apiKey: 'My API Key',
fetch: testFetch,
maxRetries: 4,
});

expect(
await client.request({
Expand Down Expand Up @@ -659,7 +687,11 @@ describe('retries', () => {
capturedRequest = init;
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};
const client = new Perplexity({ apiKey: 'My API Key', fetch: testFetch, maxRetries: 4 });
const client = new Perplexity({
apiKey: 'My API Key',
fetch: testFetch,
maxRetries: 4,
});

expect(
await client.request({
Expand Down