noodle-perplexity-mcp
Version:
A Perplexity API Model Context Protocol (MCP) server that unlocks Perplexity's search-augmented AI capabilities for LLM agents. Features robust error handling, secure input validation, transparent reasoning, and multimodal support with file attachments (P
33 lines (32 loc) • 1.27 kB
TypeScript
import { RequestContext } from '../index.js';
/**
* Defines the pricing tiers for models where cost varies by effort/context.
* 'low', 'medium', 'high' correspond to the tiers in the documentation.
*/
type ApiTier = 'high' | 'medium' | 'low';
/**
* Represents the usage data returned from the Perplexity API.
* This is extended to include potential new token types.
*/
interface UsageData {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
reasoning_tokens?: number;
citation_tokens?: number;
search_queries?: number;
}
/**
* Calculates the estimated cost of a Perplexity API call.
*
* @param model - The name of the Perplexity model used.
* @param usage - The token and action usage data from the API response.
* @param apiTier - The API tier used ('low', 'medium', 'high'), which may affect request fees.
* @param context - The request context for logging.
* @returns The estimated cost in USD, or null if pricing info is unavailable.
*/
export declare function calculatePerplexityCost(model: string, usage: UsageData, apiTier: ApiTier | undefined | null, context: RequestContext): number | null;
export declare const costTracker: {
calculatePerplexityCost: typeof calculatePerplexityCost;
};
export {};