danielrosehill commited on
Commit
82697cc
·
1 Parent(s): 69301da
analysis/context_windows_distribution.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Context Windows
3
+ ===============
4
+
5
+ Sample Size: 342
6
+
7
+ Central Tendency:
8
+ Mean: 198193.359649
9
+ Median: 131072.000000
10
+
11
+ Spread:
12
+ Min: 2824.000000
13
+ Max: 2000000.000000
14
+ Std Dev: 283137.428820
15
+ IQR: 167232.000000
16
+
17
+ Quartiles:
18
+ Q1 (25th percentile): 32768.000000
19
+ Q2 (50th percentile): 131072.000000
20
+ Q3 (75th percentile): 200000.000000
21
+
22
+ Additional Percentiles:
23
+ 10th: 30200.000000
24
+ 90th: 300000.000000
25
+ 95th: 1045206.800000
26
+ 99th: 1048576.000000
analysis/context_windows_stats.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "distribution": {
3
+ "name": "Context Windows",
4
+ "count": 342,
5
+ "min": 2824,
6
+ "max": 2000000,
7
+ "mean": 198193.3596491228,
8
+ "median": 131072.0,
9
+ "std_dev": 283137.4288197088,
10
+ "q1": 32768.0,
11
+ "q3": 200000.0,
12
+ "iqr": 167232.0,
13
+ "p10": 30200.000000000004,
14
+ "p90": 300000.0,
15
+ "p95": 1045206.7999999995,
16
+ "p99": 1048576.0
17
+ },
18
+ "stratification": {
19
+ "name": "Context Windows",
20
+ "bins": [
21
+ {
22
+ "range": "2824.000000 - 5443.537545",
23
+ "count": 8,
24
+ "percentage": 2.3391812865497075
25
+ },
26
+ {
27
+ "range": "5443.537545 - 10492.953615",
28
+ "count": 18,
29
+ "percentage": 5.263157894736842
30
+ },
31
+ {
32
+ "range": "10492.953615 - 20226.199351",
33
+ "count": 8,
34
+ "percentage": 2.3391812865497075
35
+ },
36
+ {
37
+ "range": "20226.199351 - 38987.987100",
38
+ "count": 53,
39
+ "percentage": 15.497076023391813
40
+ },
41
+ {
42
+ "range": "38987.987100 - 75153.176912",
43
+ "count": 18,
44
+ "percentage": 5.263157894736842
45
+ },
46
+ {
47
+ "range": "75153.176912 - 144865.134626",
48
+ "count": 124,
49
+ "percentage": 36.25730994152047
50
+ },
51
+ {
52
+ "range": "144865.134626 - 279241.784480",
53
+ "count": 77,
54
+ "percentage": 22.514619883040936
55
+ },
56
+ {
57
+ "range": "279241.784480 - 538265.983741",
58
+ "count": 10,
59
+ "percentage": 2.923976608187134
60
+ },
61
+ {
62
+ "range": "538265.983741 - 1037560.584969",
63
+ "count": 8,
64
+ "percentage": 2.3391812865497075
65
+ },
66
+ {
67
+ "range": "1037560.584969 - 2000000.000000",
68
+ "count": 18,
69
+ "percentage": 5.263157894736842
70
+ }
71
+ ]
72
+ }
73
+ }
analysis/context_windows_stratification.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Context Windows - Stratification
3
+ =================================
4
+
5
+ Range Distribution:
6
+ 2824.000000 - 5443.537545: 8 models ( 2.3%)
7
+ 5443.537545 - 10492.953615: 18 models ( 5.3%)
8
+ 10492.953615 - 20226.199351: 8 models ( 2.3%)
9
+ 20226.199351 - 38987.987100: 53 models ( 15.5%)
10
+ 38987.987100 - 75153.176912: 18 models ( 5.3%)
11
+ 75153.176912 - 144865.134626: 124 models ( 36.3%)
12
+ 144865.134626 - 279241.784480: 77 models ( 22.5%)
13
+ 279241.784480 - 538265.983741: 10 models ( 2.9%)
14
+ 538265.983741 - 1037560.584969: 8 models ( 2.3%)
15
+ 1037560.584969 - 2000000.000000: 18 models ( 5.3%)
analysis/input_pricing_distribution.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Input Token Pricing (per 1M tokens)
3
+ ===================================
4
+
5
+ Sample Size: 294
6
+
7
+ Central Tendency:
8
+ Mean: 1.932805
9
+ Median: 0.300000
10
+
11
+ Spread:
12
+ Min: 0.005000
13
+ Max: 150.000000
14
+ Std Dev: 9.365441
15
+ IQR: 1.000000
16
+
17
+ Quartiles:
18
+ Q1 (25th percentile): 0.100000
19
+ Q2 (50th percentile): 0.300000
20
+ Q3 (75th percentile): 1.100000
21
+
22
+ Additional Percentiles:
23
+ 10th: 0.042400
24
+ 90th: 3.000000
25
+ 95th: 5.350000
26
+ 99th: 20.700000
analysis/input_pricing_stats.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "distribution": {
3
+ "name": "Input Token Pricing (per 1M tokens)",
4
+ "count": 294,
5
+ "min": 0.005,
6
+ "max": 150.0,
7
+ "mean": 1.932804524217687,
8
+ "median": 0.3,
9
+ "std_dev": 9.365441176402692,
10
+ "q1": 0.09999999999999999,
11
+ "q3": 1.1,
12
+ "iqr": 1.0,
13
+ "p10": 0.04240000000000001,
14
+ "p90": 3.0,
15
+ "p95": 5.349999999999966,
16
+ "p99": 20.699999999999932
17
+ },
18
+ "stratification": {
19
+ "name": "Input Token Pricing",
20
+ "bins": [
21
+ {
22
+ "range": "0.005000 - 0.014018",
23
+ "count": 1,
24
+ "percentage": 0.3401360544217687
25
+ },
26
+ {
27
+ "range": "0.014018 - 0.039300",
28
+ "count": 23,
29
+ "percentage": 7.8231292517006805
30
+ },
31
+ {
32
+ "range": "0.039300 - 0.110181",
33
+ "count": 60,
34
+ "percentage": 20.408163265306122
35
+ },
36
+ {
37
+ "range": "0.110181 - 0.308900",
38
+ "count": 71,
39
+ "percentage": 24.149659863945576
40
+ },
41
+ {
42
+ "range": "0.308900 - 0.866025",
43
+ "count": 51,
44
+ "percentage": 17.346938775510203
45
+ },
46
+ {
47
+ "range": "0.866025 - 2.427967",
48
+ "count": 41,
49
+ "percentage": 13.945578231292515
50
+ },
51
+ {
52
+ "range": "2.427967 - 6.806986",
53
+ "count": 33,
54
+ "percentage": 11.224489795918368
55
+ },
56
+ {
57
+ "range": "6.806986 - 19.083895",
58
+ "count": 10,
59
+ "percentage": 3.4013605442176873
60
+ },
61
+ {
62
+ "range": "19.083895 - 53.503123",
63
+ "count": 3,
64
+ "percentage": 1.0204081632653061
65
+ },
66
+ {
67
+ "range": "53.503123 - 150.000000",
68
+ "count": 1,
69
+ "percentage": 0.3401360544217687
70
+ }
71
+ ]
72
+ }
73
+ }
analysis/input_pricing_stratification.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Input Token Pricing - Stratification
3
+ =====================================
4
+
5
+ Range Distribution:
6
+ 0.005000 - 0.014018: 1 models ( 0.3%)
7
+ 0.014018 - 0.039300: 23 models ( 7.8%)
8
+ 0.039300 - 0.110181: 60 models ( 20.4%)
9
+ 0.110181 - 0.308900: 71 models ( 24.1%)
10
+ 0.308900 - 0.866025: 51 models ( 17.3%)
11
+ 0.866025 - 2.427967: 41 models ( 13.9%)
12
+ 2.427967 - 6.806986: 33 models ( 11.2%)
13
+ 6.806986 - 19.083895: 10 models ( 3.4%)
14
+ 19.083895 - 53.503123: 3 models ( 1.0%)
15
+ 53.503123 - 150.000000: 1 models ( 0.3%)
analysis/output_input_ratio_distribution.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Output/Input Price Ratio
3
+ ========================
4
+
5
+ Sample Size: 294
6
+
7
+ Central Tendency:
8
+ Mean: 3.528242
9
+ Median: 4.000000
10
+
11
+ Spread:
12
+ Min: 0.800000
13
+ Max: 11.666667
14
+ Std Dev: 1.909742
15
+ IQR: 2.166667
16
+
17
+ Quartiles:
18
+ Q1 (25th percentile): 2.000000
19
+ Q2 (50th percentile): 4.000000
20
+ Q3 (75th percentile): 4.166667
21
+
22
+ Additional Percentiles:
23
+ 10th: 1.000000
24
+ 90th: 5.000000
25
+ 95th: 8.000000
26
+ 99th: 8.450000
analysis/output_input_ratio_stats.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "distribution": {
3
+ "name": "Output/Input Price Ratio",
4
+ "count": 294,
5
+ "min": 0.8,
6
+ "max": 11.666666666666664,
7
+ "mean": 3.5282415447399473,
8
+ "median": 4.0,
9
+ "std_dev": 1.9097416372501397,
10
+ "q1": 2.0,
11
+ "q3": 4.166666666666667,
12
+ "iqr": 2.166666666666667,
13
+ "p10": 1.0,
14
+ "p90": 5.0,
15
+ "p95": 8.0,
16
+ "p99": 8.449999999999989
17
+ },
18
+ "stratification": {
19
+ "name": "Output/Input Price Ratio",
20
+ "bins": [
21
+ {
22
+ "range": "0.800000 - 1.045865",
23
+ "count": 40,
24
+ "percentage": 13.60544217687075
25
+ },
26
+ {
27
+ "range": "1.045865 - 1.367292",
28
+ "count": 7,
29
+ "percentage": 2.380952380952381
30
+ },
31
+ {
32
+ "range": "1.367292 - 1.787504",
33
+ "count": 21,
34
+ "percentage": 7.142857142857142
35
+ },
36
+ {
37
+ "range": "1.787504 - 2.336860",
38
+ "count": 20,
39
+ "percentage": 6.802721088435375
40
+ },
41
+ {
42
+ "range": "2.336860 - 3.055050",
43
+ "count": 38,
44
+ "percentage": 12.925170068027212
45
+ },
46
+ {
47
+ "range": "3.055050 - 3.993963",
48
+ "count": 20,
49
+ "percentage": 6.802721088435375
50
+ },
51
+ {
52
+ "range": "3.993963 - 5.221433",
53
+ "count": 121,
54
+ "percentage": 41.156462585034014
55
+ },
56
+ {
57
+ "range": "5.221433 - 6.826144",
58
+ "count": 7,
59
+ "percentage": 2.380952380952381
60
+ },
61
+ {
62
+ "range": "6.826144 - 8.924032",
63
+ "count": 17,
64
+ "percentage": 5.782312925170068
65
+ },
66
+ {
67
+ "range": "8.924032 - 11.666667",
68
+ "count": 2,
69
+ "percentage": 0.6802721088435374
70
+ }
71
+ ]
72
+ }
73
+ }
analysis/output_input_ratio_stratification.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Output/Input Price Ratio - Stratification
3
+ ==========================================
4
+
5
+ Range Distribution:
6
+ 0.800000 - 1.045865: 40 models ( 13.6%)
7
+ 1.045865 - 1.367292: 7 models ( 2.4%)
8
+ 1.367292 - 1.787504: 21 models ( 7.1%)
9
+ 1.787504 - 2.336860: 20 models ( 6.8%)
10
+ 2.336860 - 3.055050: 38 models ( 12.9%)
11
+ 3.055050 - 3.993963: 20 models ( 6.8%)
12
+ 3.993963 - 5.221433: 121 models ( 41.2%)
13
+ 5.221433 - 6.826144: 7 models ( 2.4%)
14
+ 6.826144 - 8.924032: 17 models ( 5.8%)
15
+ 8.924032 - 11.666667: 2 models ( 0.7%)
analysis/output_pricing_distribution.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Output Token Pricing (per 1M tokens)
3
+ ====================================
4
+
5
+ Sample Size: 294
6
+
7
+ Central Tendency:
8
+ Mean: 7.074562
9
+ Median: 1.000000
10
+
11
+ Spread:
12
+ Min: 0.010000
13
+ Max: 600.000000
14
+ Std Dev: 37.152968
15
+ IQR: 3.700000
16
+
17
+ Quartiles:
18
+ Q1 (25th percentile): 0.300000
19
+ Q2 (50th percentile): 1.000000
20
+ Q3 (75th percentile): 4.000000
21
+
22
+ Additional Percentiles:
23
+ 10th: 0.103000
24
+ 90th: 10.000000
25
+ 95th: 15.000000
26
+ 99th: 75.350000
analysis/output_pricing_stats.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "distribution": {
3
+ "name": "Output Token Pricing (per 1M tokens)",
4
+ "count": 294,
5
+ "min": 0.01,
6
+ "max": 600.0,
7
+ "mean": 7.074561746938776,
8
+ "median": 1.0,
9
+ "std_dev": 37.152967606908874,
10
+ "q1": 0.3,
11
+ "q3": 4.0,
12
+ "iqr": 3.7,
13
+ "p10": 0.10300000000000001,
14
+ "p90": 10.0,
15
+ "p95": 15.0,
16
+ "p99": 75.34999999999997
17
+ },
18
+ "stratification": {
19
+ "name": "Output Token Pricing",
20
+ "bins": [
21
+ {
22
+ "range": "0.010000 - 0.030048",
23
+ "count": 4,
24
+ "percentage": 1.3605442176870748
25
+ },
26
+ {
27
+ "range": "0.030048 - 0.090288",
28
+ "count": 15,
29
+ "percentage": 5.1020408163265305
30
+ },
31
+ {
32
+ "range": "0.090288 - 0.271297",
33
+ "count": 48,
34
+ "percentage": 16.3265306122449
35
+ },
36
+ {
37
+ "range": "0.271297 - 0.815193",
38
+ "count": 69,
39
+ "percentage": 23.46938775510204
40
+ },
41
+ {
42
+ "range": "0.815193 - 2.449490",
43
+ "count": 70,
44
+ "percentage": 23.809523809523807
45
+ },
46
+ {
47
+ "range": "2.449490 - 7.360219",
48
+ "count": 37,
49
+ "percentage": 12.585034013605442
50
+ },
51
+ {
52
+ "range": "7.360219 - 22.115964",
53
+ "count": 38,
54
+ "percentage": 12.925170068027212
55
+ },
56
+ {
57
+ "range": "22.115964 - 66.453981",
58
+ "count": 7,
59
+ "percentage": 2.380952380952381
60
+ },
61
+ {
62
+ "range": "66.453981 - 199.680716",
63
+ "count": 5,
64
+ "percentage": 1.7006802721088436
65
+ },
66
+ {
67
+ "range": "199.680716 - 600.000000",
68
+ "count": 0,
69
+ "percentage": 0.0
70
+ }
71
+ ]
72
+ }
73
+ }
analysis/output_pricing_stratification.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Output Token Pricing - Stratification
3
+ ======================================
4
+
5
+ Range Distribution:
6
+ 0.010000 - 0.030048: 4 models ( 1.4%)
7
+ 0.030048 - 0.090288: 15 models ( 5.1%)
8
+ 0.090288 - 0.271297: 48 models ( 16.3%)
9
+ 0.271297 - 0.815193: 69 models ( 23.5%)
10
+ 0.815193 - 2.449490: 70 models ( 23.8%)
11
+ 2.449490 - 7.360219: 37 models ( 12.6%)
12
+ 7.360219 - 22.115964: 38 models ( 12.9%)
13
+ 22.115964 - 66.453981: 7 models ( 2.4%)
14
+ 66.453981 - 199.680716: 5 models ( 1.7%)
15
+ 199.680716 - 600.000000: 0 models ( 0.0%)
analysis/pricing_analysis.py ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ OpenRouter API Pricing Analysis
4
+ Analyzes context windows, token pricing, and output/input ratios
5
+ """
6
+
7
+ import json
8
+ import numpy as np
9
+ from pathlib import Path
10
+ from typing import Dict, List, Any
11
+ import statistics
12
+
13
+ def load_data(file_path: str) -> List[Dict[str, Any]]:
14
+ """Load the models data from JSON file"""
15
+ with open(file_path, 'r') as f:
16
+ return json.load(f)
17
+
18
+ def calculate_distribution_stats(values: List[float], name: str) -> Dict[str, Any]:
19
+ """Calculate comprehensive distribution statistics"""
20
+ if not values:
21
+ return {"error": "No data"}
22
+
23
+ values = sorted(values)
24
+ n = len(values)
25
+
26
+ stats = {
27
+ "name": name,
28
+ "count": n,
29
+ "min": min(values),
30
+ "max": max(values),
31
+ "mean": statistics.mean(values),
32
+ "median": statistics.median(values),
33
+ "std_dev": statistics.stdev(values) if n > 1 else 0,
34
+ }
35
+
36
+ # Quartiles
37
+ stats["q1"] = np.percentile(values, 25)
38
+ stats["q3"] = np.percentile(values, 75)
39
+ stats["iqr"] = stats["q3"] - stats["q1"]
40
+
41
+ # Additional percentiles
42
+ stats["p10"] = np.percentile(values, 10)
43
+ stats["p90"] = np.percentile(values, 90)
44
+ stats["p95"] = np.percentile(values, 95)
45
+ stats["p99"] = np.percentile(values, 99)
46
+
47
+ return stats
48
+
49
+ def calculate_stratification(values: List[float], name: str) -> Dict[str, Any]:
50
+ """Calculate stratification by creating bins/ranges"""
51
+ if not values:
52
+ return {"error": "No data"}
53
+
54
+ values_array = np.array(values)
55
+
56
+ # Determine appropriate bins based on data range
57
+ min_val = values_array.min()
58
+ max_val = values_array.max()
59
+
60
+ # Create stratification bins
61
+ if max_val - min_val < 1:
62
+ # For very small ranges (like some pricing)
63
+ bins = np.linspace(min_val, max_val, 11)
64
+ else:
65
+ # Use log scale for wide ranges
66
+ if min_val > 0:
67
+ bins = np.logspace(np.log10(max(min_val, 0.0001)), np.log10(max_val), 11)
68
+ else:
69
+ bins = np.linspace(min_val, max_val, 11)
70
+
71
+ hist, bin_edges = np.histogram(values_array, bins=bins)
72
+
73
+ stratification = {
74
+ "name": name,
75
+ "bins": []
76
+ }
77
+
78
+ for i in range(len(hist)):
79
+ stratification["bins"].append({
80
+ "range": f"{bin_edges[i]:.6f} - {bin_edges[i+1]:.6f}",
81
+ "count": int(hist[i]),
82
+ "percentage": float(hist[i] / len(values) * 100)
83
+ })
84
+
85
+ return stratification
86
+
87
+ def analyze_context_windows(models: List[Dict[str, Any]]) -> tuple:
88
+ """Analyze context window distribution"""
89
+ context_lengths = [
90
+ m['context_length']
91
+ for m in models
92
+ if m.get('context_length') and m['context_length'] > 0
93
+ ]
94
+
95
+ distribution = calculate_distribution_stats(context_lengths, "Context Windows")
96
+ stratification = calculate_stratification(context_lengths, "Context Windows")
97
+
98
+ return distribution, stratification
99
+
100
+ def analyze_input_pricing(models: List[Dict[str, Any]]) -> tuple:
101
+ """Analyze input token pricing distribution"""
102
+ input_prices = [
103
+ m['prompt_price_per_1m_tokens']
104
+ for m in models
105
+ if m.get('prompt_price_per_1m_tokens') is not None and m['prompt_price_per_1m_tokens'] > 0
106
+ ]
107
+
108
+ distribution = calculate_distribution_stats(input_prices, "Input Token Pricing (per 1M tokens)")
109
+ stratification = calculate_stratification(input_prices, "Input Token Pricing")
110
+
111
+ return distribution, stratification
112
+
113
+ def analyze_output_pricing(models: List[Dict[str, Any]]) -> tuple:
114
+ """Analyze output token pricing distribution"""
115
+ output_prices = [
116
+ m['completion_price_per_1m_tokens']
117
+ for m in models
118
+ if m.get('completion_price_per_1m_tokens') is not None and m['completion_price_per_1m_tokens'] > 0
119
+ ]
120
+
121
+ distribution = calculate_distribution_stats(output_prices, "Output Token Pricing (per 1M tokens)")
122
+ stratification = calculate_stratification(output_prices, "Output Token Pricing")
123
+
124
+ return distribution, stratification
125
+
126
+ def analyze_output_input_ratio(models: List[Dict[str, Any]]) -> tuple:
127
+ """Analyze output/input token price ratio"""
128
+ ratios = []
129
+
130
+ for m in models:
131
+ input_price = m.get('prompt_price_per_1m_tokens', 0)
132
+ output_price = m.get('completion_price_per_1m_tokens', 0)
133
+
134
+ # Calculate ratio only for non-free models
135
+ if input_price > 0 and output_price > 0:
136
+ ratio = output_price / input_price
137
+ ratios.append(ratio)
138
+
139
+ distribution = calculate_distribution_stats(ratios, "Output/Input Price Ratio")
140
+ stratification = calculate_stratification(ratios, "Output/Input Price Ratio")
141
+
142
+ return distribution, stratification
143
+
144
+ def format_distribution_report(dist: Dict[str, Any]) -> str:
145
+ """Format distribution statistics as readable text"""
146
+ if "error" in dist:
147
+ return f"Error: {dist['error']}"
148
+
149
+ report = f"""
150
+ {dist['name']}
151
+ {'=' * len(dist['name'])}
152
+
153
+ Sample Size: {dist['count']:,}
154
+
155
+ Central Tendency:
156
+ Mean: {dist['mean']:.6f}
157
+ Median: {dist['median']:.6f}
158
+
159
+ Spread:
160
+ Min: {dist['min']:.6f}
161
+ Max: {dist['max']:.6f}
162
+ Std Dev: {dist['std_dev']:.6f}
163
+ IQR: {dist['iqr']:.6f}
164
+
165
+ Quartiles:
166
+ Q1 (25th percentile): {dist['q1']:.6f}
167
+ Q2 (50th percentile): {dist['median']:.6f}
168
+ Q3 (75th percentile): {dist['q3']:.6f}
169
+
170
+ Additional Percentiles:
171
+ 10th: {dist['p10']:.6f}
172
+ 90th: {dist['p90']:.6f}
173
+ 95th: {dist['p95']:.6f}
174
+ 99th: {dist['p99']:.6f}
175
+ """
176
+ return report
177
+
178
+ def format_stratification_report(strat: Dict[str, Any]) -> str:
179
+ """Format stratification as readable text"""
180
+ if "error" in strat:
181
+ return f"Error: {strat['error']}"
182
+
183
+ report = f"""
184
+ {strat['name']} - Stratification
185
+ {'=' * (len(strat['name']) + 18)}
186
+
187
+ Range Distribution:
188
+ """
189
+
190
+ for bin_data in strat['bins']:
191
+ report += f" {bin_data['range']:>40s}: {bin_data['count']:>6,} models ({bin_data['percentage']:>5.1f}%)\n"
192
+
193
+ return report
194
+
195
+ def main():
196
+ # Load data
197
+ data_file = Path(__file__).parent.parent / 'raw' / 'models.json'
198
+ models = load_data(data_file)
199
+
200
+ print(f"Loaded {len(models)} models\n")
201
+
202
+ # Create output directory
203
+ output_dir = Path(__file__).parent
204
+ output_dir.mkdir(exist_ok=True)
205
+
206
+ # Analyze each metric
207
+ analyses = {
208
+ 'context_windows': analyze_context_windows(models),
209
+ 'input_pricing': analyze_input_pricing(models),
210
+ 'output_pricing': analyze_output_pricing(models),
211
+ 'output_input_ratio': analyze_output_input_ratio(models)
212
+ }
213
+
214
+ # Generate reports for each analysis
215
+ for metric_name, (distribution, stratification) in analyses.items():
216
+ # Create individual report files
217
+ dist_report = format_distribution_report(distribution)
218
+ strat_report = format_stratification_report(stratification)
219
+
220
+ # Write distribution report
221
+ dist_file = output_dir / f"{metric_name}_distribution.txt"
222
+ with open(dist_file, 'w') as f:
223
+ f.write(dist_report)
224
+ print(f"Created: {dist_file}")
225
+
226
+ # Write stratification report
227
+ strat_file = output_dir / f"{metric_name}_stratification.txt"
228
+ with open(strat_file, 'w') as f:
229
+ f.write(strat_report)
230
+ print(f"Created: {strat_file}")
231
+
232
+ # Also save as JSON for programmatic access
233
+ json_file = output_dir / f"{metric_name}_stats.json"
234
+ with open(json_file, 'w') as f:
235
+ json.dump({
236
+ 'distribution': distribution,
237
+ 'stratification': stratification
238
+ }, f, indent=2)
239
+ print(f"Created: {json_file}")
240
+
241
+ # Create comprehensive summary report
242
+ summary_file = output_dir / "summary_report.txt"
243
+ with open(summary_file, 'w') as f:
244
+ f.write("OpenRouter API Pricing Analysis - Summary Report\n")
245
+ f.write("=" * 60 + "\n\n")
246
+ f.write(f"Dataset: {len(models)} models analyzed\n\n")
247
+
248
+ for metric_name, (distribution, stratification) in analyses.items():
249
+ f.write("\n" + "=" * 60 + "\n")
250
+ f.write(format_distribution_report(distribution))
251
+ f.write("\n")
252
+ f.write(format_stratification_report(stratification))
253
+ f.write("\n")
254
+
255
+ print(f"\nCreated: {summary_file}")
256
+ print("\nAnalysis complete!")
257
+
258
+ if __name__ == "__main__":
259
+ main()
analysis/summary_report.txt ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ OpenRouter API Pricing Analysis - Summary Report
2
+ ============================================================
3
+
4
+ Dataset: 342 models analyzed
5
+
6
+
7
+ ============================================================
8
+
9
+ Context Windows
10
+ ===============
11
+
12
+ Sample Size: 342
13
+
14
+ Central Tendency:
15
+ Mean: 198193.359649
16
+ Median: 131072.000000
17
+
18
+ Spread:
19
+ Min: 2824.000000
20
+ Max: 2000000.000000
21
+ Std Dev: 283137.428820
22
+ IQR: 167232.000000
23
+
24
+ Quartiles:
25
+ Q1 (25th percentile): 32768.000000
26
+ Q2 (50th percentile): 131072.000000
27
+ Q3 (75th percentile): 200000.000000
28
+
29
+ Additional Percentiles:
30
+ 10th: 30200.000000
31
+ 90th: 300000.000000
32
+ 95th: 1045206.800000
33
+ 99th: 1048576.000000
34
+
35
+
36
+ Context Windows - Stratification
37
+ =================================
38
+
39
+ Range Distribution:
40
+ 2824.000000 - 5443.537545: 8 models ( 2.3%)
41
+ 5443.537545 - 10492.953615: 18 models ( 5.3%)
42
+ 10492.953615 - 20226.199351: 8 models ( 2.3%)
43
+ 20226.199351 - 38987.987100: 53 models ( 15.5%)
44
+ 38987.987100 - 75153.176912: 18 models ( 5.3%)
45
+ 75153.176912 - 144865.134626: 124 models ( 36.3%)
46
+ 144865.134626 - 279241.784480: 77 models ( 22.5%)
47
+ 279241.784480 - 538265.983741: 10 models ( 2.9%)
48
+ 538265.983741 - 1037560.584969: 8 models ( 2.3%)
49
+ 1037560.584969 - 2000000.000000: 18 models ( 5.3%)
50
+
51
+
52
+ ============================================================
53
+
54
+ Input Token Pricing (per 1M tokens)
55
+ ===================================
56
+
57
+ Sample Size: 294
58
+
59
+ Central Tendency:
60
+ Mean: 1.932805
61
+ Median: 0.300000
62
+
63
+ Spread:
64
+ Min: 0.005000
65
+ Max: 150.000000
66
+ Std Dev: 9.365441
67
+ IQR: 1.000000
68
+
69
+ Quartiles:
70
+ Q1 (25th percentile): 0.100000
71
+ Q2 (50th percentile): 0.300000
72
+ Q3 (75th percentile): 1.100000
73
+
74
+ Additional Percentiles:
75
+ 10th: 0.042400
76
+ 90th: 3.000000
77
+ 95th: 5.350000
78
+ 99th: 20.700000
79
+
80
+
81
+ Input Token Pricing - Stratification
82
+ =====================================
83
+
84
+ Range Distribution:
85
+ 0.005000 - 0.014018: 1 models ( 0.3%)
86
+ 0.014018 - 0.039300: 23 models ( 7.8%)
87
+ 0.039300 - 0.110181: 60 models ( 20.4%)
88
+ 0.110181 - 0.308900: 71 models ( 24.1%)
89
+ 0.308900 - 0.866025: 51 models ( 17.3%)
90
+ 0.866025 - 2.427967: 41 models ( 13.9%)
91
+ 2.427967 - 6.806986: 33 models ( 11.2%)
92
+ 6.806986 - 19.083895: 10 models ( 3.4%)
93
+ 19.083895 - 53.503123: 3 models ( 1.0%)
94
+ 53.503123 - 150.000000: 1 models ( 0.3%)
95
+
96
+
97
+ ============================================================
98
+
99
+ Output Token Pricing (per 1M tokens)
100
+ ====================================
101
+
102
+ Sample Size: 294
103
+
104
+ Central Tendency:
105
+ Mean: 7.074562
106
+ Median: 1.000000
107
+
108
+ Spread:
109
+ Min: 0.010000
110
+ Max: 600.000000
111
+ Std Dev: 37.152968
112
+ IQR: 3.700000
113
+
114
+ Quartiles:
115
+ Q1 (25th percentile): 0.300000
116
+ Q2 (50th percentile): 1.000000
117
+ Q3 (75th percentile): 4.000000
118
+
119
+ Additional Percentiles:
120
+ 10th: 0.103000
121
+ 90th: 10.000000
122
+ 95th: 15.000000
123
+ 99th: 75.350000
124
+
125
+
126
+ Output Token Pricing - Stratification
127
+ ======================================
128
+
129
+ Range Distribution:
130
+ 0.010000 - 0.030048: 4 models ( 1.4%)
131
+ 0.030048 - 0.090288: 15 models ( 5.1%)
132
+ 0.090288 - 0.271297: 48 models ( 16.3%)
133
+ 0.271297 - 0.815193: 69 models ( 23.5%)
134
+ 0.815193 - 2.449490: 70 models ( 23.8%)
135
+ 2.449490 - 7.360219: 37 models ( 12.6%)
136
+ 7.360219 - 22.115964: 38 models ( 12.9%)
137
+ 22.115964 - 66.453981: 7 models ( 2.4%)
138
+ 66.453981 - 199.680716: 5 models ( 1.7%)
139
+ 199.680716 - 600.000000: 0 models ( 0.0%)
140
+
141
+
142
+ ============================================================
143
+
144
+ Output/Input Price Ratio
145
+ ========================
146
+
147
+ Sample Size: 294
148
+
149
+ Central Tendency:
150
+ Mean: 3.528242
151
+ Median: 4.000000
152
+
153
+ Spread:
154
+ Min: 0.800000
155
+ Max: 11.666667
156
+ Std Dev: 1.909742
157
+ IQR: 2.166667
158
+
159
+ Quartiles:
160
+ Q1 (25th percentile): 2.000000
161
+ Q2 (50th percentile): 4.000000
162
+ Q3 (75th percentile): 4.166667
163
+
164
+ Additional Percentiles:
165
+ 10th: 1.000000
166
+ 90th: 5.000000
167
+ 95th: 8.000000
168
+ 99th: 8.450000
169
+
170
+
171
+ Output/Input Price Ratio - Stratification
172
+ ==========================================
173
+
174
+ Range Distribution:
175
+ 0.800000 - 1.045865: 40 models ( 13.6%)
176
+ 1.045865 - 1.367292: 7 models ( 2.4%)
177
+ 1.367292 - 1.787504: 21 models ( 7.1%)
178
+ 1.787504 - 2.336860: 20 models ( 6.8%)
179
+ 2.336860 - 3.055050: 38 models ( 12.9%)
180
+ 3.055050 - 3.993963: 20 models ( 6.8%)
181
+ 3.993963 - 5.221433: 121 models ( 41.2%)
182
+ 5.221433 - 6.826144: 7 models ( 2.4%)
183
+ 6.826144 - 8.924032: 17 models ( 5.8%)
184
+ 8.924032 - 11.666667: 2 models ( 0.7%)
185
+