UNPKG

@callmedayz/ai-prompt-toolkit

Version:

Professional AI prompt engineering toolkit with advanced template features, real-time dashboards, conditional logic, template inheritance, live monitoring, OpenRouter integration, and 310+ model support

67 lines 2.23 kB
import { TokenCountResult, SupportedModel, ModelConfig } from './types'; import { OpenRouterClient } from './openrouter-client'; /** * Token counting utility for various AI models */ export declare class TokenCounter { private static readonly MODEL_CONFIGS; private static client; private static tokenizationService; /** * Set the OpenRouter client for real tokenization */ static setClient(client: OpenRouterClient): void; /** * Create client from API key */ static setApiKey(apiKey: string): void; /** * Get accurate token count using OpenRouter's tokenization service */ static getTokenCount(text: string, model?: SupportedModel): Promise<TokenCountResult>; /** * Get detailed token count with native tokenizer information */ static getDetailedTokenCount(text: string, model?: SupportedModel): Promise<TokenCountResult & { generationId?: string; nativeTokens?: number; }>; /** * Compare estimation accuracy against real API tokenization */ static compareTokenCounts(text: string, model?: SupportedModel): Promise<{ estimated: TokenCountResult; actual: TokenCountResult; difference: number; accuracy: number; }>; /** * Estimate token count for a given text (fallback method) * This is a rough estimation based on character count and word patterns */ static estimateTokens(text: string, model?: SupportedModel): TokenCountResult; /** * Check if text fits within model's token limit */ static fitsInModel(text: string, model: SupportedModel): boolean; /** * Get model configuration */ static getModelConfig(model: SupportedModel): ModelConfig; /** * Get all supported models */ static getSupportedModels(): SupportedModel[]; /** * Find the best model for a given text length */ static recommendModel(text: string): { model: SupportedModel; reason: string; }; /** * Calculate cost for processing text with a specific model */ static calculateCost(text: string, model: SupportedModel): number; } //# sourceMappingURL=token-counter.d.ts.map