llm-test-bench 0.1.0

A production-grade CLI for testing and benchmarking LLM applications with support for GPT-5, Claude Opus 4, Gemini 2.5, and 65+ models
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
use anyhow::{Context, Result};
use clap::Args;
use colored::Colorize;
use llm_test_bench_core::config::{AnalyticsConfig, ConfigLoader};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

#[derive(Args, Debug)]
pub struct OptimizeArgs {
    /// Current model being used
    #[arg(short = 'm', long, required = true)]
    pub current_model: String,

    /// Quality threshold (0.0-1.0)
    #[arg(short, long, default_value = "0.75")]
    pub quality_threshold: f64,

    /// Monthly request volume
    #[arg(short = 'r', long, required = true)]
    pub monthly_requests: usize,

    /// Historical results for analysis
    #[arg(long)]
    pub history: Option<PathBuf>,

    /// Maximum acceptable cost increase (%)
    #[arg(long, default_value = "10.0")]
    pub max_cost_increase: f64,

    /// Minimum required quality score
    #[arg(long, default_value = "0.70")]
    pub min_quality: f64,

    /// Include experimental models
    #[arg(long)]
    pub include_experimental: bool,

    /// Output format
    #[arg(short, long, default_value = "detailed")]
    pub output: OutputFormat,

    /// Save optimization report
    #[arg(long)]
    pub report_file: Option<PathBuf>,

    /// Path to custom configuration file
    #[arg(long)]
    pub config: Option<PathBuf>,
}

#[derive(Debug, Clone, PartialEq, clap::ValueEnum)]
pub enum OutputFormat {
    Detailed,
    Summary,
    Json,
}

#[derive(Debug, Serialize, Deserialize)]
struct OptimizationReport {
    current_model: ModelAnalysis,
    recommendations: Vec<ModelRecommendation>,
    cost_savings: CostSavings,
    risk_assessment: RiskAssessment,
    summary: String,
}

#[derive(Debug, Serialize, Deserialize)]
struct ModelAnalysis {
    name: String,
    provider: String,
    monthly_cost: f64,
    avg_quality: f64,
    avg_latency: f64,
    tokens_per_request: f64,
}

#[derive(Debug, Serialize, Deserialize)]
struct ModelRecommendation {
    rank: usize,
    model: String,
    provider: String,
    monthly_cost: f64,
    cost_savings_amount: f64,
    cost_savings_percent: f64,
    estimated_quality: f64,
    quality_change: f64,
    avg_latency: f64,
    latency_change: f64,
    reason: String,
    pros: Vec<String>,
    cons: Vec<String>,
}

#[derive(Debug, Serialize, Deserialize)]
struct CostSavings {
    total_annual_savings: f64,
    best_recommendation_savings: f64,
    roi_percentage: f64,
}

#[derive(Debug, Serialize, Deserialize)]
struct RiskAssessment {
    overall_risk: String,
    quality_risk: String,
    cost_risk: String,
    recommendations: Vec<String>,
}

// Model pricing database (per 1K tokens)
struct ModelPricing {
    input_cost: f64,
    output_cost: f64,
}

pub async fn execute(args: OptimizeArgs, verbose: bool) -> Result<()> {
    println!("{}", "LLM Test Bench - Optimize Command".bold().cyan());
    println!();

    // Validate arguments
    if args.quality_threshold < 0.0 || args.quality_threshold > 1.0 {
        anyhow::bail!("Quality threshold must be between 0.0 and 1.0, got: {}", args.quality_threshold);
    }

    if args.monthly_requests == 0 {
        anyhow::bail!("Monthly requests must be greater than 0");
    }

    if verbose {
        println!("{}", "Configuration:".bold());
        println!("  Current model: {}", args.current_model);
        println!("  Quality threshold: {:.2}", args.quality_threshold);
        println!("  Monthly requests: {}", args.monthly_requests);
        println!("  Min quality: {:.2}", args.min_quality);
        println!();
    }

    // Load configuration
    let config_loader = if let Some(ref config_path) = args.config {
        ConfigLoader::new().with_file(config_path)
    } else {
        ConfigLoader::new()
    };
    let config = config_loader.load().context("Failed to load configuration")?;
    let analytics_config = config.analytics.unwrap_or_default();

    // Analyze current model
    println!("{} Analyzing current model: {}", "".green(), args.current_model.bold());
    let current_analysis = analyze_current_model(&args, &analytics_config)?;
    println!("  {} Monthly cost: ${:.2}", "".blue(), current_analysis.monthly_cost);
    println!("  {} Avg quality: {:.2}", "".blue(), current_analysis.avg_quality);
    println!("  {} Avg latency: {:.0}ms", "".blue(), current_analysis.avg_latency);
    println!();

    // Generate recommendations
    println!("{} Generating optimization recommendations...", "".green());
    let recommendations = generate_recommendations(&current_analysis, &args, &analytics_config)?;
    println!("  {} Found {} alternative model(s)", "".green(), recommendations.len());
    println!();

    // Calculate cost savings
    let cost_savings = calculate_cost_savings(&current_analysis, &recommendations)?;

    // Assess risks
    let risk_assessment = assess_risks(&current_analysis, &recommendations, &args)?;

    // Create report
    let summary = generate_summary(&current_analysis, &recommendations, &cost_savings);
    let report = OptimizationReport {
        current_model: current_analysis,
        recommendations,
        cost_savings,
        risk_assessment,
        summary,
    };

    // Display results
    display_optimization_report(&report, &args, verbose)?;

    // Save report if requested
    if let Some(ref report_path) = args.report_file {
        save_report(&report, report_path)?;
        println!();
        println!("{} Report saved to: {}", "".green(), report_path.display().to_string().cyan());
    }

    println!();
    println!("{} Optimization analysis complete!", "".green().bold());

    Ok(())
}

fn analyze_current_model(args: &OptimizeArgs, _config: &AnalyticsConfig) -> Result<ModelAnalysis> {
    let (provider, model) = parse_model_spec(&args.current_model)?;

    // Get pricing for current model
    let pricing = get_model_pricing(&provider, &model);

    // Estimate token usage (simplified - in production, use historical data)
    let avg_input_tokens = 500.0;
    let avg_output_tokens = 300.0;
    let tokens_per_request = avg_input_tokens + avg_output_tokens;

    // Calculate monthly cost
    let cost_per_request = (avg_input_tokens * pricing.input_cost + avg_output_tokens * pricing.output_cost) / 1000.0;
    let monthly_cost = cost_per_request * args.monthly_requests as f64;

    // Estimate quality based on model tier (simplified)
    let avg_quality = estimate_model_quality(&provider, &model);

    // Estimate latency based on model
    let avg_latency = estimate_model_latency(&provider, &model);

    Ok(ModelAnalysis {
        name: model,
        provider,
        monthly_cost,
        avg_quality,
        avg_latency,
        tokens_per_request,
    })
}

fn parse_model_spec(spec: &str) -> Result<(String, String)> {
    let parts: Vec<&str> = spec.split(':').collect();
    if parts.len() == 2 {
        Ok((parts[0].to_string(), parts[1].to_string()))
    } else {
        // Infer provider from model name
        if spec.contains("gpt") {
            Ok(("openai".to_string(), spec.to_string()))
        } else if spec.contains("claude") {
            Ok(("anthropic".to_string(), spec.to_string()))
        } else {
            anyhow::bail!("Cannot infer provider from model '{}'. Use format: provider:model", spec)
        }
    }
}

fn get_model_pricing(provider: &str, model: &str) -> ModelPricing {
    match (provider, model) {
        ("openai", m) if m.contains("gpt-4-turbo") => ModelPricing {
            input_cost: 10.0,
            output_cost: 30.0,
        },
        ("openai", m) if m.contains("gpt-4") => ModelPricing {
            input_cost: 30.0,
            output_cost: 60.0,
        },
        ("openai", m) if m.contains("gpt-3.5-turbo") => ModelPricing {
            input_cost: 0.5,
            output_cost: 1.5,
        },
        ("anthropic", m) if m.contains("opus") => ModelPricing {
            input_cost: 15.0,
            output_cost: 75.0,
        },
        ("anthropic", m) if m.contains("sonnet") => ModelPricing {
            input_cost: 3.0,
            output_cost: 15.0,
        },
        ("anthropic", m) if m.contains("haiku") => ModelPricing {
            input_cost: 0.25,
            output_cost: 1.25,
        },
        _ => ModelPricing {
            input_cost: 1.0,
            output_cost: 2.0,
        },
    }
}

fn estimate_model_quality(provider: &str, model: &str) -> f64 {
    match (provider, model) {
        ("openai", m) if m.contains("gpt-4") => 0.92,
        ("openai", m) if m.contains("gpt-3.5-turbo") => 0.78,
        ("anthropic", m) if m.contains("opus") => 0.94,
        ("anthropic", m) if m.contains("sonnet") => 0.88,
        ("anthropic", m) if m.contains("haiku") => 0.82,
        _ => 0.75,
    }
}

fn estimate_model_latency(provider: &str, model: &str) -> f64 {
    match (provider, model) {
        ("openai", m) if m.contains("gpt-4") && !m.contains("turbo") => 2500.0,
        ("openai", m) if m.contains("gpt-4-turbo") => 1200.0,
        ("openai", m) if m.contains("gpt-3.5") => 800.0,
        ("anthropic", m) if m.contains("opus") => 2000.0,
        ("anthropic", m) if m.contains("sonnet") => 1000.0,
        ("anthropic", m) if m.contains("haiku") => 500.0,
        _ => 1000.0,
    }
}

fn generate_recommendations(
    current: &ModelAnalysis,
    args: &OptimizeArgs,
    _config: &AnalyticsConfig,
) -> Result<Vec<ModelRecommendation>> {
    let mut recommendations = Vec::new();

    // Define candidate models
    let mut candidates = vec![
        ("openai", "gpt-4-turbo"),
        ("openai", "gpt-4"),
        ("openai", "gpt-3.5-turbo"),
        ("anthropic", "claude-3-opus"),
        ("anthropic", "claude-3-sonnet"),
        ("anthropic", "claude-3-haiku"),
    ];

    // Filter out current model
    candidates.retain(|(p, m)| {
        format!("{}:{}", p, m) != format!("{}:{}", current.provider, current.name)
    });

    // Analyze each candidate
    for (rank, (provider, model)) in candidates.iter().enumerate() {
        let pricing = get_model_pricing(provider, model);
        let quality = estimate_model_quality(provider, model);
        let latency = estimate_model_latency(provider, model);

        // Calculate cost
        let avg_input_tokens = 500.0;
        let avg_output_tokens = 300.0;
        let cost_per_request = (avg_input_tokens * pricing.input_cost + avg_output_tokens * pricing.output_cost) / 1000.0;
        let monthly_cost = cost_per_request * args.monthly_requests as f64;

        // Check if meets criteria
        if quality < args.min_quality {
            continue;
        }

        if quality < args.quality_threshold {
            continue;
        }

        let cost_savings_amount = current.monthly_cost - monthly_cost;
        let cost_savings_percent = (cost_savings_amount / current.monthly_cost) * 100.0;

        // Skip if cost increase exceeds threshold
        if cost_savings_amount < 0.0 && cost_savings_percent.abs() > args.max_cost_increase {
            continue;
        }

        let quality_change = quality - current.avg_quality;
        let latency_change = latency - current.avg_latency;

        // Generate reason
        let reason = if cost_savings_amount > 0.0 && quality_change >= 0.0 {
            format!("Saves ${:.2}/month while maintaining or improving quality", cost_savings_amount)
        } else if cost_savings_amount > 0.0 {
            format!("Saves ${:.2}/month ({:.1}% reduction)", cost_savings_amount, cost_savings_percent)
        } else if quality_change > 0.0 {
            format!("Improves quality by {:.2} points", quality_change)
        } else {
            "Alternative option".to_string()
        };

        // Generate pros and cons
        let mut pros = Vec::new();
        let mut cons = Vec::new();

        if cost_savings_amount > 0.0 {
            pros.push(format!("${:.2}/month cost savings ({:.1}%)", cost_savings_amount, cost_savings_percent));
        }
        if quality_change > 0.0 {
            pros.push(format!("+{:.2} quality improvement", quality_change));
        }
        if latency_change < 0.0 {
            pros.push(format!("{:.0}ms faster response time", latency_change.abs()));
        }

        if cost_savings_amount < 0.0 {
            cons.push(format!("${:.2}/month additional cost", cost_savings_amount.abs()));
        }
        if quality_change < 0.0 {
            cons.push(format!("{:.2} quality decrease", quality_change.abs()));
        }
        if latency_change > 0.0 {
            cons.push(format!("+{:.0}ms slower response time", latency_change));
        }

        recommendations.push(ModelRecommendation {
            rank: rank + 1,
            model: model.to_string(),
            provider: provider.to_string(),
            monthly_cost,
            cost_savings_amount,
            cost_savings_percent,
            estimated_quality: quality,
            quality_change,
            avg_latency: latency,
            latency_change,
            reason,
            pros,
            cons,
        });
    }

    // Sort by cost savings (descending)
    recommendations.sort_by(|a, b| {
        b.cost_savings_amount.partial_cmp(&a.cost_savings_amount).unwrap_or(std::cmp::Ordering::Equal)
    });

    // Update ranks
    for (idx, rec) in recommendations.iter_mut().enumerate() {
        rec.rank = idx + 1;
    }

    Ok(recommendations)
}

fn calculate_cost_savings(
    _current: &ModelAnalysis,
    recommendations: &[ModelRecommendation],
) -> Result<CostSavings> {
    let best_savings = recommendations
        .first()
        .map(|r| r.cost_savings_amount)
        .unwrap_or(0.0);

    let total_annual_savings = best_savings * 12.0;

    let roi_percentage = if best_savings > 0.0 {
        100.0 // Simplified - assume minimal switching cost
    } else {
        0.0
    };

    Ok(CostSavings {
        total_annual_savings,
        best_recommendation_savings: best_savings,
        roi_percentage,
    })
}

fn assess_risks(
    current: &ModelAnalysis,
    recommendations: &[ModelRecommendation],
    args: &OptimizeArgs,
) -> Result<RiskAssessment> {
    let best_rec = recommendations.first();

    let quality_risk = if let Some(rec) = best_rec {
        if rec.quality_change < -0.05 {
            "High - Significant quality decrease expected".to_string()
        } else if rec.quality_change < 0.0 {
            "Medium - Minor quality decrease expected".to_string()
        } else {
            "Low - Quality maintained or improved".to_string()
        }
    } else {
        "N/A - No recommendations available".to_string()
    };

    let cost_risk = if let Some(rec) = best_rec {
        if rec.cost_savings_percent < -10.0 {
            "High - Significant cost increase".to_string()
        } else if rec.cost_savings_percent < 0.0 {
            "Medium - Minor cost increase".to_string()
        } else {
            "Low - Cost reduction expected".to_string()
        }
    } else {
        "N/A".to_string()
    };

    let overall_risk = if quality_risk.contains("High") || cost_risk.contains("High") {
        "High".to_string()
    } else if quality_risk.contains("Medium") || cost_risk.contains("Medium") {
        "Medium".to_string()
    } else {
        "Low".to_string()
    };

    let mut risk_recommendations = Vec::new();

    if overall_risk == "High" {
        risk_recommendations.push("Run A/B tests before full migration".to_string());
        risk_recommendations.push("Monitor quality metrics closely during transition".to_string());
    } else if overall_risk == "Medium" {
        risk_recommendations.push("Gradual rollout recommended (e.g., 10% -> 50% -> 100%)".to_string());
        risk_recommendations.push("Set up quality alerts before migration".to_string());
    } else {
        risk_recommendations.push("Safe to proceed with migration".to_string());
        risk_recommendations.push("Standard monitoring procedures sufficient".to_string());
    }

    Ok(RiskAssessment {
        overall_risk,
        quality_risk,
        cost_risk,
        recommendations: risk_recommendations,
    })
}

fn generate_summary(
    current: &ModelAnalysis,
    recommendations: &[ModelRecommendation],
    cost_savings: &CostSavings,
) -> String {
    if recommendations.is_empty() {
        format!(
            "No better alternatives found for {} that meet your quality threshold of {:.2}.",
            current.name, current.avg_quality
        )
    } else {
        let best = &recommendations[0];
        if cost_savings.best_recommendation_savings > 0.0 {
            format!(
                "Switch to {}:{} to save ${:.2}/month (${:.2}/year) while {} quality.",
                best.provider,
                best.model,
                cost_savings.best_recommendation_savings,
                cost_savings.total_annual_savings,
                if best.quality_change >= 0.0 { "maintaining or improving" } else { "slightly reducing" }
            )
        } else {
            format!(
                "Consider {}:{} for improved quality ({:.2} vs {:.2}), though at ${:.2}/month additional cost.",
                best.provider, best.model, best.estimated_quality, current.avg_quality, best.cost_savings_amount.abs()
            )
        }
    }
}

fn display_optimization_report(report: &OptimizationReport, args: &OptimizeArgs, verbose: bool) -> Result<()> {
    match args.output {
        OutputFormat::Json => {
            let json = serde_json::to_string_pretty(report)?;
            println!("{}", json);
        }
        OutputFormat::Summary | OutputFormat::Detailed => {
            println!("{}", "Optimization Report".bold().cyan());
            println!("{}", "".repeat(80).dimmed());
            println!();

            // Current model analysis
            println!("{}", "Current Model".bold());
            println!("  Model: {}:{}", report.current_model.provider, report.current_model.name);
            println!("  Monthly cost: ${:.2}", report.current_model.monthly_cost);
            println!("  Quality score: {:.2}", report.current_model.avg_quality);
            println!("  Avg latency: {:.0}ms", report.current_model.avg_latency);
            println!();

            // Recommendations
            if report.recommendations.is_empty() {
                println!("{}", "No Recommendations".yellow().bold());
                println!("  No alternative models found that meet your criteria.");
                println!("  Consider lowering quality threshold or accepting higher costs.");
            } else {
                println!("{} Recommendation{}", "Top".bold().green(), if report.recommendations.len() > 1 { "s" } else { "" });
                println!();

                let display_count = if args.output == OutputFormat::Summary {
                    3.min(report.recommendations.len())
                } else {
                    report.recommendations.len()
                };

                for rec in &report.recommendations[..display_count] {
                    let savings_color = if rec.cost_savings_amount > 0.0 { "green" } else { "yellow" };

                    println!("{}. {}:{}", rec.rank, rec.provider.bold(), rec.model.bold());
                    println!("   {}", rec.reason.dimmed());
                    println!("   Monthly cost: ${:.2} ({}${:.2}, {:.1}%)",
                        rec.monthly_cost,
                        if rec.cost_savings_amount > 0.0 { "-" } else { "+" },
                        rec.cost_savings_amount.abs(),
                        rec.cost_savings_percent.abs()
                    );
                    println!("   Quality: {:.2} ({}{:.2})",
                        rec.estimated_quality,
                        if rec.quality_change >= 0.0 { "+" } else { "" },
                        rec.quality_change
                    );
                    println!("   Latency: {:.0}ms ({}{:.0}ms)",
                        rec.avg_latency,
                        if rec.latency_change >= 0.0 { "+" } else { "" },
                        rec.latency_change
                    );

                    if verbose {
                        if !rec.pros.is_empty() {
                            println!("   Pros:");
                            for pro in &rec.pros {
                                println!("     + {}", pro.green());
                            }
                        }
                        if !rec.cons.is_empty() {
                            println!("   Cons:");
                            for con in &rec.cons {
                                println!("     - {}", con.yellow());
                            }
                        }
                    }
                    println!();
                }
            }

            // Cost savings
            if report.cost_savings.total_annual_savings > 0.0 {
                println!("{}", "Potential Savings".bold().green());
                println!("  Monthly: ${:.2}", report.cost_savings.best_recommendation_savings);
                println!("  Annual: ${:.2}", report.cost_savings.total_annual_savings);
                println!("  ROI: {:.0}%", report.cost_savings.roi_percentage);
                println!();
            }

            // Risk assessment
            println!("{}", "Risk Assessment".bold().yellow());
            let risk_color = match report.risk_assessment.overall_risk.as_str() {
                "High" => "red",
                "Medium" => "yellow",
                _ => "green",
            };
            print!("  Overall risk: ");
            match risk_color {
                "red" => println!("{}", report.risk_assessment.overall_risk.red()),
                "yellow" => println!("{}", report.risk_assessment.overall_risk.yellow()),
                _ => println!("{}", report.risk_assessment.overall_risk.green()),
            }
            println!("  Quality risk: {}", report.risk_assessment.quality_risk);
            println!("  Cost risk: {}", report.risk_assessment.cost_risk);
            println!();

            println!("{}", "Recommendations:".dimmed());
            for rec in &report.risk_assessment.recommendations {
                println!("{}", rec);
            }
            println!();

            // Summary
            println!("{}", "Summary".bold().cyan());
            println!("  {}", report.summary);
        }
    }

    Ok(())
}

fn save_report(report: &OptimizationReport, path: &PathBuf) -> Result<()> {
    let json = serde_json::to_string_pretty(report)?;
    std::fs::write(path, json)?;
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_parse_model_spec() {
        let (provider, model) = parse_model_spec("openai:gpt-4").unwrap();
        assert_eq!(provider, "openai");
        assert_eq!(model, "gpt-4");

        let (provider, model) = parse_model_spec("gpt-4").unwrap();
        assert_eq!(provider, "openai");
        assert_eq!(model, "gpt-4");
    }

    #[test]
    fn test_model_pricing() {
        let pricing = get_model_pricing("openai", "gpt-4");
        assert!(pricing.input_cost > 0.0);
        assert!(pricing.output_cost > 0.0);
    }

    #[test]
    fn test_estimate_model_quality() {
        let quality = estimate_model_quality("openai", "gpt-4");
        assert!(quality >= 0.8 && quality <= 1.0);
    }
}