Files
claude-task-master/src/ai-providers/perplexity.js
Ralph Khreish 6a8a68e1a3 Feat/add.azure.and.other.providers (#607)
* fix: claude-4 not having the right max_tokens

* feat: add bedrock support

* chore: fix package-lock.json

* fix: rename baseUrl to baseURL

* feat: add azure support

* fix: final touches of azure integration

* feat: add google vertex provider

* chore: fix tests and refactor task-manager.test.js

* chore: move task 92 to 94
2025-05-28 00:42:31 +02:00

40 lines
1.0 KiB
JavaScript

/**
* perplexity.js
* AI provider implementation for Perplexity models using Vercel AI SDK.
*/
import { createPerplexity } from '@ai-sdk/perplexity';
import { BaseAIProvider } from './base-provider.js';
export class PerplexityAIProvider extends BaseAIProvider {
constructor() {
super();
this.name = 'Perplexity';
}
/**
* Creates and returns a Perplexity client instance.
* @param {object} params - Parameters for client initialization
* @param {string} params.apiKey - Perplexity API key
* @param {string} [params.baseURL] - Optional custom API endpoint
* @returns {Function} Perplexity client function
* @throws {Error} If API key is missing or initialization fails
*/
getClient(params) {
try {
const { apiKey, baseURL } = params;
if (!apiKey) {
throw new Error('Perplexity API key is required.');
}
return createPerplexity({
apiKey,
baseURL: baseURL || 'https://api.perplexity.ai'
});
} catch (error) {
this.handleError('client initialization', error);
}
}
}