Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 5,582 Bytes
d32c69c |
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 |
# Cost per 1K tokens for different models
costs = {
"openai": {
"gpt-4": {"input": 0.03, "output": 0.06},
"gpt-4o": {"input": 0.0025, "output": 0.01},
"gpt-4.5-preview": {"input": 0.075, "output": 0.15},
"gpt-4o-mini": {"input": 0.00015, "output": 0.0006},
"gpt-3.5-turbo": {"input": 0.0005, "output": 0.0015},
"o1": {"input": 0.015, "output": 0.06},
"o1-mini": {"input": 0.00011, "output": 0.00044},
"o3-mini": {"input": 0.00011, "output": 0.00044}
},
"anthropic": {
"claude-3-opus-latest": {"input": 0.015, "output": 0.075},
"claude-3-7-sonnet-latest": {"input": 0.003, "output": 0.015},
"claude-3-5-sonnet-latest": {"input": 0.003, "output": 0.015},
"claude-3-5-haiku-latest": {"input": 0.0008, "output": 0.0004},
},
"groq": {
"deepseek-r1-distill-qwen-32b": {"input": 0.00075, "output": 0.00099},
"deepseek-r1-distill-llama-70b": {"input": 0.00075, "output": 0.00099},
"llama-3.3-70b-versatile": {"input": 0.00059, "output": 0.00079},
"llama-3.3-70b-specdec": {"input": 0.00059, "output": 0.00099},
"llama2-70b-4096": {"input": 0.0007, "output": 0.0008},
"llama3-8b-8192": {"input": 0.00005, "output": 0.00008},
"llama-3.2-1b-preview": {"input": 0.00004, "output": 0.00004},
"llama-3.2-3b-preview": {"input": 0.00006, "output": 0.00006},
"llama-3.2-11b-text-preview": {"input": 0.00018, "output": 0.00018},
"llama-3.2-11b-vision-preview": {"input": 0.00018, "output": 0.00018},
"llama-3.2-90b-text-preview": {"input": 0.0009, "output": 0.0009},
"llama-3.2-90b-vision-preview": {"input": 0.0009, "output": 0.0009},
"llama3-70b-8192": {"input": 0.00059, "output": 0.00079},
"llama-3.1-8b-instant": {"input": 0.00005, "output": 0.00008},
"llama-3.1-70b-versatile": {"input": 0.00059, "output": 0.00079},
"llama-3.1-405b-reasoning": {"input": 0.00059, "output": 0.00079},
"mixtral-8x7b-32768": {"input": 0.00024, "output": 0.00024},
"gemma-7b-it": {"input": 0.00007, "output": 0.00007},
"gemma2-9b-it": {"input": 0.0002, "output": 0.0002},
"llama3-groq-70b-8192-tool-use-preview": {"input": 0.00089, "output": 0.00089},
"llama3-groq-8b-8192-tool-use-preview": {"input": 0.00019, "output": 0.00019},
"qwen-2.5-coder-32b": {"input": 0.0015, "output": 0.003}
}
}
# divide models in 3 tiers based on cost per 1k tokens
# tier 1: < $0.0005
# tier 2: $0.0005 - $0.001
# tier 3: > $0.001
def get_tier(model_name):
for provider, models in costs.items():
for model, cost in models.items():
if model == model_name:
return cost
return None
def get_tier_1():
tier_1 = []
for provider, models in costs.items():
for model, cost in models.items():
if cost["input"] + cost["output"] < 0.0005:
tier_1.append(model)
return tier_1
def get_tier_2():
tier_2 = []
for provider, models in costs.items():
for model, cost in models.items():
if cost["input"] + cost["output"] >= 0.0005 and cost["input"] + cost["output"] < 0.001:
tier_2.append(model)
return tier_2
def get_tier_3():
tier_3 = []
for provider, models in costs.items():
for model, cost in models.items():
if cost["input"] + cost["output"] >= 0.001:
tier_3.append(model)
return tier_3
model_tiers = {
"tier1": {
"name": "Basic",
"credits": 1,
"models": get_tier_1()
},
"tier2": {
"name": "Standard",
"credits": 3,
"models": get_tier_2()
},
"tier3": {
"name": "Premium",
"credits": 5,
"models": get_tier_3()
}
}
import json
print(json.dumps(model_tiers, indent=4))
"""
{
"tier1": {
"name": "Basic",
"credits": 1,
"models": [
"llama3-8b-8192",
"llama-3.2-1b-preview",
"llama-3.2-3b-preview",
"llama-3.2-11b-text-preview",
"llama-3.2-11b-vision-preview",
"llama-3.1-8b-instant",
"mixtral-8x7b-32768",
"gemma-7b-it",
"gemma2-9b-it",
"llama3-groq-8b-8192-tool-use-preview"
]
},
"tier2": {
"name": "Standard",
"credits": 3,
"models": [
"gpt-4o-mini",
"o1-mini",
"o3-mini"
]
},
"tier3": {
"name": "Premium",
"credits": 5,
"models": [
"gpt-3.5-turbo",
"gpt-4.5-preview",
"gpt-4",
"gpt-4o",
"o1",
"claude-3-opus-latest",
"claude-3-7-sonnet-latest",
"claude-3-5-sonnet-latest",
"qwen-2.5-coder-32b",
"claude-3-5-haiku-latest",
"deepseek-r1-distill-qwen-32b",
"deepseek-r1-distill-llama-70b",
"llama-3.3-70b-versatile",
"llama-3.3-70b-specdec",
"llama2-70b-4096",
"llama-3.2-90b-text-preview",
"llama-3.2-90b-vision-preview",
"llama3-70b-8192",
"llama-3.1-70b-versatile",
"llama-3.1-405b-reasoning",
"llama3-groq-70b-8192-tool-use-preview"
]
}
}
""" |