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
1 change: 1 addition & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ export class Perplexity implements SdkTransport {
{
Accept: 'application/json',
'User-Agent': this.getUserAgent(),
'X-Pplx-Integration': 'perplexity-node/' + VERSION,
'X-Source': 'perplexity-node',
'X-Title': 'Perplexity Node SDK',
},
Expand Down
11 changes: 11 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Chat as LegacyChat } from './resources/chat/chat.js';
import { Completions as LegacyChatCompletions } from './resources/chat/completions.js';
import { Files as LegacyResponseFiles } from './resources/responses/files.js';
import { Responses as LegacyResponses } from './resources/responses/responses.js';
import { VERSION } from './version.js';
const defaultFetch = fetch;

describe('instantiate client', () => {
Expand Down Expand Up @@ -109,6 +110,16 @@ describe('instantiate client', () => {
it('they are used in the request', async () => {
const { req } = await client.buildRequest({ path: '/foo', method: 'post' });
assert.deepStrictEqual(req.headers.get('x-my-default-header'), '2');
assert.deepStrictEqual(req.headers.get('x-pplx-integration'), `perplexity-node/${VERSION}`);
});

it('can override the integration attribution header', async () => {
const { req } = await client.buildRequest({
path: '/foo',
method: 'post',
headers: { 'X-Pplx-Integration': 'custom-integration/1.0.0' },
});
assert.deepStrictEqual(req.headers.get('x-pplx-integration'), 'custom-integration/1.0.0');
});

it('can ignore `undefined` and leave the default', async () => {
Expand Down