Upload data3/show_pricing.py with huggingface_hub
Browse files- data3/show_pricing.py +100 -0
data3/show_pricing.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Display OpenAI model pricing and cost estimates
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
PRICING = {
|
| 7 |
+
# GPT-5 series
|
| 8 |
+
("gpt-5.2", "GPT-5.2", "更高质量"): (1.75, 14.00),
|
| 9 |
+
("gpt-5.1", "GPT-5.1", "高质量"): (1.25, 10.00),
|
| 10 |
+
("gpt-5", "GPT-5", "高质量"): (1.25, 10.00),
|
| 11 |
+
("gpt-5-mini", "GPT-5 Mini", "较便宜"): (0.25, 2.00),
|
| 12 |
+
("gpt-5-nano", "GPT-5 Nano", "最便宜"): (0.05, 0.40),
|
| 13 |
+
# GPT-5 Pro
|
| 14 |
+
("gpt-5.2-pro", "GPT-5.2 Pro", "顶级质量"): (21.00, 168.00),
|
| 15 |
+
("gpt-5-pro", "GPT-5 Pro", "顶级质量"): (15.00, 120.00),
|
| 16 |
+
# GPT-4.1 series
|
| 17 |
+
("gpt-4.1", "GPT-4.1", "平衡选择"): (2.00, 8.00),
|
| 18 |
+
("gpt-4.1-mini", "GPT-4.1 Mini", "经济实惠"): (0.40, 1.60),
|
| 19 |
+
("gpt-4.1-nano", "GPT-4.1 Nano", "超低成本"): (0.10, 0.40),
|
| 20 |
+
# GPT-4o series (recommended)
|
| 21 |
+
("gpt-4o", "GPT-4o ⭐", "质量优秀"): (2.50, 10.00),
|
| 22 |
+
("gpt-4o-mini", "GPT-4o Mini ⭐⭐", "性价比最高"): (0.15, 0.60),
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
def calculate_cost(input_price, output_price, input_tokens=2000, output_tokens=1500):
|
| 26 |
+
"""Calculate cost for given token counts"""
|
| 27 |
+
input_cost = (input_tokens / 1_000_000) * input_price
|
| 28 |
+
output_cost = (output_tokens / 1_000_000) * output_price
|
| 29 |
+
return input_cost + output_cost
|
| 30 |
+
|
| 31 |
+
def main():
|
| 32 |
+
print("=" * 90)
|
| 33 |
+
print("OPENAI MODEL PRICING & COST ESTIMATES (Dec 2024)")
|
| 34 |
+
print("=" * 90)
|
| 35 |
+
print()
|
| 36 |
+
|
| 37 |
+
# Assumptions
|
| 38 |
+
input_tokens = 2000
|
| 39 |
+
output_tokens = 1500
|
| 40 |
+
|
| 41 |
+
print(f"Assumptions: {input_tokens:,} input tokens + {output_tokens:,} output tokens per problem")
|
| 42 |
+
print()
|
| 43 |
+
|
| 44 |
+
# Header
|
| 45 |
+
print(f"{'Model':<25} {'Input':<12} {'Output':<12} {'Per Prob':<12} {'100 Probs':<12} {'1000 Probs':<12}")
|
| 46 |
+
print("-" * 90)
|
| 47 |
+
|
| 48 |
+
# Sort by cost per problem
|
| 49 |
+
model_costs = []
|
| 50 |
+
for (model_id, model_name, desc), (input_price, output_price) in PRICING.items():
|
| 51 |
+
cost_per_problem = calculate_cost(input_price, output_price, input_tokens, output_tokens)
|
| 52 |
+
model_costs.append((model_name, input_price, output_price, cost_per_problem, desc))
|
| 53 |
+
|
| 54 |
+
model_costs.sort(key=lambda x: x[3]) # Sort by cost per problem
|
| 55 |
+
|
| 56 |
+
for model_name, input_price, output_price, cost_per_problem, desc in model_costs:
|
| 57 |
+
cost_100 = cost_per_problem * 100
|
| 58 |
+
cost_1000 = cost_per_problem * 1000
|
| 59 |
+
|
| 60 |
+
print(f"{model_name:<25} ${input_price:<11.2f} ${output_price:<11.2f} "
|
| 61 |
+
f"${cost_per_problem:<11.6f} ${cost_100:<11.2f} ${cost_1000:<11.2f}")
|
| 62 |
+
|
| 63 |
+
print("-" * 90)
|
| 64 |
+
print()
|
| 65 |
+
|
| 66 |
+
# Recommendations
|
| 67 |
+
print("RECOMMENDATIONS:")
|
| 68 |
+
print(" ⭐⭐ gpt-4o-mini: Best cost-effectiveness for large batches")
|
| 69 |
+
print(" ⭐ gpt-4o: Best quality-to-cost ratio for high-quality datasets")
|
| 70 |
+
print(" 💰 gpt-4.1-nano or gpt-5-nano: Cheapest options for experiments")
|
| 71 |
+
print(" 🏆 gpt-5-pro/gpt-5.2-pro: Premium options for critical applications")
|
| 72 |
+
print()
|
| 73 |
+
|
| 74 |
+
# Sample budgets
|
| 75 |
+
print("SAMPLE BUDGETS:")
|
| 76 |
+
print()
|
| 77 |
+
|
| 78 |
+
recommended = [
|
| 79 |
+
("gpt-5-nano", "Budget Testing", 0.05, 0.40),
|
| 80 |
+
("gpt-4.1-nano", "Low Budget", 0.10, 0.40),
|
| 81 |
+
("gpt-4o-mini", "Recommended ⭐", 0.15, 0.60),
|
| 82 |
+
("gpt-4.1-mini", "Mid Budget", 0.40, 1.60),
|
| 83 |
+
("gpt-4o", "High Quality ⭐", 2.50, 10.00),
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
+
budget_amounts = [1.0, 5.0, 10.0, 20.0, 50.0]
|
| 87 |
+
|
| 88 |
+
for model_id, label, input_p, output_p in recommended:
|
| 89 |
+
cost_per = calculate_cost(input_p, output_p, input_tokens, output_tokens)
|
| 90 |
+
print(f"\n{label} ({model_id}):")
|
| 91 |
+
print(f" Cost per problem: ${cost_per:.6f}")
|
| 92 |
+
counts = [int(budget / cost_per) for budget in budget_amounts]
|
| 93 |
+
budget_str = " | ".join([f"${b}→{c:,}" for b, c in zip(budget_amounts, counts)])
|
| 94 |
+
print(f" Problems: {budget_str}")
|
| 95 |
+
|
| 96 |
+
print()
|
| 97 |
+
print("=" * 90)
|
| 98 |
+
|
| 99 |
+
if __name__ == "__main__":
|
| 100 |
+
main()
|