From acb7d2ab7377eb47073b3aa459a592ef4ae5ff10 Mon Sep 17 00:00:00 2001 From: Saleh Alghusson <1331721+qirh@users.noreply.github.com> Date: Mon, 24 Aug 2026 21:23:03 +0000 Subject: [PATCH] feat: add X-Pplx-Integration attribution header --- src/client.ts | 1 + src/index.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/client.ts b/src/client.ts index c61d62a..6437da4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -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', }, diff --git a/src/index.test.ts b/src/index.test.ts index b9880a8..06bc586 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -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', () => { @@ -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 () => {