/** * Comprehensive Cost and Budget Types * All pricing, billing, and cost tracking definitions */ import { ModelProvider } from './vendors'; export interface CostRecord { id: string; project_id: string; request_id: string; connector_id: string; provider: ModelProvider; model: string; timestamp: Date; cost_breakdown: CostBreakdown; total_cost: number; currency: string; user_id?: string; tags?: Record; } export interface CostBreakdown { input_tokens: number; output_tokens: number; input_cost: number; output_cost: number; base_cost: number; additional_costs?: AdditionalCost[]; discounts?: Discount[]; } export interface AdditionalCost { type: AdditionalCostType; description: string; amount: number; quantity?: number; unit_price?: number; } export declare enum AdditionalCostType { FUNCTION_CALLING = "function_calling", VISION_PROCESSING = "vision_processing", AUDIO_PROCESSING = "audio_processing", EMBEDDING = "embedding", FINE_TUNING = "fine_tuning", CACHING = "caching", PRIORITY_PROCESSING = "priority_processing", DATA_TRANSFER = "data_transfer", STORAGE = "storage", CUSTOM = "custom" } export interface Discount { type: DiscountType; description: string; amount: number; percentage?: number; } export declare enum DiscountType { VOLUME = "volume", COMMITMENT = "commitment", PROMOTIONAL = "promotional", PARTNER = "partner", EARLY_ADOPTER = "early_adopter", CUSTOM = "custom" } export interface PricingModel { provider: ModelProvider; model: string; model_version?: string; pricing_tiers: PricingTier[]; effective_date: Date; expiry_date?: Date; currency: string; billing_unit: BillingUnit; metadata?: Record; } export declare enum BillingUnit { TOKEN = "token", CHARACTER = "character", REQUEST = "request", SECOND = "second", MINUTE = "minute", IMAGE = "image", AUDIO_SECOND = "audio_second" } export interface PricingTier { tier_name: string; min_volume: number; max_volume?: number; input_price_per_unit: number; output_price_per_unit: number; base_price?: number; conditions?: PricingCondition[]; } export interface PricingCondition { attribute: PricingAttribute; operator: 'eq' | 'gt' | 'lt' | 'in'; value: string | number | string[]; } export declare enum PricingAttribute { USAGE_TYPE = "usage_type", REGION = "region", COMMITMENT_LEVEL = "commitment_level", CUSTOMER_TIER = "customer_tier", TIME_OF_DAY = "time_of_day" } export interface Budget { id: string; project_id: string; name: string; description?: string; budget_type: BudgetType; amount: number; currency: string; period: BudgetPeriod; start_date: Date; end_date?: Date; status: BudgetStatus; alerts: BudgetAlert[]; actions: BudgetAction[]; actual_spend: number; forecasted_spend?: number; created_at: Date; updated_at: Date; } export declare enum BudgetType { HARD_LIMIT = "hard_limit", SOFT_LIMIT = "soft_limit", FORECAST = "forecast" } export declare enum BudgetPeriod { DAILY = "daily", WEEKLY = "weekly", MONTHLY = "monthly", QUARTERLY = "quarterly", YEARLY = "yearly", CUSTOM = "custom" } export declare enum BudgetStatus { ACTIVE = "active", EXCEEDED = "exceeded", PAUSED = "paused", EXPIRED = "expired" } export interface BudgetAlert { id: string; threshold_percentage: number; notification_channels: NotificationChannel[]; triggered: boolean; last_triggered_at?: Date; } export interface NotificationChannel { type: NotificationChannelType; config: NotificationChannelConfig; } export declare enum NotificationChannelType { EMAIL = "email", WEBHOOK = "webhook", SMS = "sms", SLACK = "slack", PAGERDUTY = "pagerduty", CUSTOM = "custom" } export type NotificationChannelConfig = EmailNotificationConfig | WebhookNotificationConfig | SMSNotificationConfig | SlackNotificationConfig | PagerDutyNotificationConfig | CustomNotificationConfig; export interface EmailNotificationConfig { type: NotificationChannelType.EMAIL; recipients: string[]; subject_template?: string; body_template?: string; } export interface WebhookNotificationConfig { type: NotificationChannelType.WEBHOOK; url: string; headers?: Record; retry_config?: { max_attempts: number; backoff_multiplier: number; }; } export interface SMSNotificationConfig { type: NotificationChannelType.SMS; phone_numbers: string[]; message_template?: string; } export interface SlackNotificationConfig { type: NotificationChannelType.SLACK; webhook_url: string; channel?: string; username?: string; icon_emoji?: string; } export interface PagerDutyNotificationConfig { type: NotificationChannelType.PAGERDUTY; routing_key: string; severity: 'critical' | 'error' | 'warning' | 'info'; } export interface CustomNotificationConfig { type: NotificationChannelType.CUSTOM; endpoint: string; config: Record; } export interface BudgetAction { id: string; trigger_percentage: number; action_type: BudgetActionType; config: BudgetActionConfig; executed: boolean; last_executed_at?: Date; } export declare enum BudgetActionType { BLOCK_REQUESTS = "block_requests", THROTTLE_REQUESTS = "throttle_requests", DOWNGRADE_MODELS = "downgrade_models", NOTIFY_ADMIN = "notify_admin", CUSTOM = "custom" } export type BudgetActionConfig = BlockRequestsConfig | ThrottleRequestsConfig | DowngradeModelsConfig | NotifyAdminConfig | CustomActionConfig; export interface BlockRequestsConfig { action_type: BudgetActionType.BLOCK_REQUESTS; exempted_users?: string[]; exempted_connectors?: string[]; grace_period_minutes?: number; } export interface ThrottleRequestsConfig { action_type: BudgetActionType.THROTTLE_REQUESTS; throttle_percentage: number; apply_to?: 'all' | 'specific_users' | 'specific_connectors'; target_ids?: string[]; } export interface DowngradeModelsConfig { action_type: BudgetActionType.DOWNGRADE_MODELS; downgrades: Array<{ from_connector_id: string; to_connector_id: string; }>; notify_users: boolean; } export interface NotifyAdminConfig { action_type: BudgetActionType.NOTIFY_ADMIN; admin_emails: string[]; include_details: boolean; } export interface CustomActionConfig { action_type: BudgetActionType.CUSTOM; webhook_url: string; config: Record; } export interface CostAllocation { id: string; project_id: string; period_start: Date; period_end: Date; total_cost: number; currency: string; allocations: AllocationBreakdown[]; generated_at: Date; } export interface AllocationBreakdown { dimension: AllocationDimension; allocations: Array<{ key: string; value: string; cost: number; percentage: number; request_count: number; }>; } export declare enum AllocationDimension { PROVIDER = "provider", MODEL = "model", USER = "user", DEPARTMENT = "department", COST_CENTER = "cost_center", ENVIRONMENT = "environment", TAG = "tag", CONNECTOR = "connector", DAY = "day", HOUR = "hour" } export interface CostOptimizationRecommendation { id: string; project_id: string; type: OptimizationType; title: string; description: string; potential_savings: number; potential_savings_percentage: number; confidence: 'low' | 'medium' | 'high'; impact: 'low' | 'medium' | 'high'; effort: 'low' | 'medium' | 'high'; recommendation_details: OptimizationDetails; status: RecommendationStatus; created_at: Date; expires_at?: Date; } export declare enum OptimizationType { MODEL_DOWNGRADE = "model_downgrade", CACHING = "caching", BATCH_PROCESSING = "batch_processing", PROMPT_OPTIMIZATION = "prompt_optimization", RATE_LIMITING = "rate_limiting", REGIONAL_PRICING = "regional_pricing", COMMITMENT_DISCOUNT = "commitment_discount", PROVIDER_SWITCH = "provider_switch" } export type OptimizationDetails = ModelDowngradeDetails | CachingDetails | BatchProcessingDetails | PromptOptimizationDetails | RateLimitingDetails | RegionalPricingDetails | CommitmentDiscountDetails | ProviderSwitchDetails; export interface ModelDowngradeDetails { type: OptimizationType.MODEL_DOWNGRADE; current_connector_id: string; suggested_connector_id: string; quality_impact_percentage: number; use_cases: string[]; } export interface CachingDetails { type: OptimizationType.CACHING; cache_hit_rate_current: number; cache_hit_rate_potential: number; repeated_prompts_percentage: number; ttl_recommendation_seconds: number; } export interface BatchProcessingDetails { type: OptimizationType.BATCH_PROCESSING; current_request_pattern: 'real-time'; suggested_pattern: 'batch'; batch_size_recommendation: number; latency_impact_seconds: number; } export interface PromptOptimizationDetails { type: OptimizationType.PROMPT_OPTIMIZATION; average_prompt_length_current: number; average_prompt_length_optimized: number; token_savings_per_request: number; optimization_suggestions: string[]; } export interface RateLimitingDetails { type: OptimizationType.RATE_LIMITING; current_rate: number; suggested_rate: number; peak_usage_hours: number[]; off_peak_discount_available: boolean; } export interface RegionalPricingDetails { type: OptimizationType.REGIONAL_PRICING; current_region: string; suggested_region: string; price_difference_percentage: number; latency_impact_ms: number; } export interface CommitmentDiscountDetails { type: OptimizationType.COMMITMENT_DISCOUNT; commitment_level: 'monthly' | 'yearly'; commitment_amount: number; discount_percentage: number; break_even_months: number; } export interface ProviderSwitchDetails { type: OptimizationType.PROVIDER_SWITCH; current_provider: ModelProvider; suggested_provider: ModelProvider; price_difference_percentage: number; feature_parity: boolean; migration_effort: 'low' | 'medium' | 'high'; } export declare enum RecommendationStatus { NEW = "new", VIEWED = "viewed", ACCEPTED = "accepted", REJECTED = "rejected", IMPLEMENTED = "implemented", EXPIRED = "expired" } export interface Invoice { id: string; project_id: string; invoice_number: string; billing_period_start: Date; billing_period_end: Date; issue_date: Date; due_date: Date; status: InvoiceStatus; line_items: InvoiceLineItem[]; subtotal: number; tax: number; total: number; currency: string; payment_method?: PaymentMethod; metadata?: Record; } export declare enum InvoiceStatus { DRAFT = "draft", PENDING = "pending", PAID = "paid", OVERDUE = "overdue", CANCELLED = "cancelled" } export interface InvoiceLineItem { description: string; quantity: number; unit_price: number; amount: number; provider?: ModelProvider; model?: string; period_start?: Date; period_end?: Date; } export interface PaymentMethod { type: PaymentMethodType; last_four?: string; expiry_date?: string; billing_address?: Address; } export declare enum PaymentMethodType { CREDIT_CARD = "credit_card", BANK_TRANSFER = "bank_transfer", PAYPAL = "paypal", INVOICE = "invoice", CUSTOM = "custom" } export interface Address { street: string; city: string; state?: string; postal_code: string; country: string; } export interface CostAnalysis { project_id: string; analysis_period: { start: Date; end: Date; }; summary: CostSummary; trends: CostTrend[]; top_cost_drivers: CostDriver[]; anomalies: CostAnomaly[]; generated_at: Date; } export interface CostSummary { total_cost: number; average_cost_per_request: number; total_requests: number; total_tokens: number; cost_by_provider: Record; cost_by_model: Record; growth_rate_percentage: number; } export interface CostTrend { timestamp: Date; cost: number; request_count: number; average_cost_per_request: number; } export interface CostDriver { type: 'provider' | 'model' | 'user' | 'connector'; identifier: string; cost: number; percentage_of_total: number; request_count: number; } export interface CostAnomaly { detected_at: Date; type: AnomalyType; severity: 'low' | 'medium' | 'high'; description: string; metric: string; expected_value: number; actual_value: number; deviation_percentage: number; } export declare enum AnomalyType { SPIKE = "spike", DROP = "drop", UNUSUAL_PATTERN = "unusual_pattern", COST_OVERRUN = "cost_overrun" } //# sourceMappingURL=costs.d.ts.map