n8n/packages/nodes-base/credentials/PerplexityApi.credentials.ts
Bernhard Wittmann 67af2e177d
feat(core): Add opt-in RFC-style outbound User-Agent via env flag (#28771)
Co-authored-by: Muhammad Osama <muhammadosama984@gmail.com>
2026-04-27 06:01:09 +00:00

54 lines
1.1 KiB
TypeScript

import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class PerplexityApi implements ICredentialType {
name = 'perplexityApi';
displayName = 'Perplexity API';
documentationUrl = 'perplexity';
properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
typeOptions: { password: true },
required: true,
default: '',
description: 'Your Perplexity API key. Get it from your Perplexity account.',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bearer {{$credentials.apiKey}}',
'X-Source': 'n8n',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.perplexity.ai',
url: '/chat/completions',
method: 'POST',
body: {
model: 'sonar',
messages: [{ role: 'user', content: 'test' }],
},
headers: {
Authorization: '=Bearer {{$credentials.apiKey}}',
'Content-Type': 'application/json',
},
json: true,
},
};
}