API Examples
Real-world usage patterns for the BenchGecko API.
Find the Cheapest Model Above a Score Threshold
import requests
# Get all models scoring above 85 on average, sorted by price
response = requests.get("https://benchgecko.ai/api/v1/models", params={
"min_score": 85,
"sort": "price",
"order": "asc",
"limit": 5
})
for model in response.json()["data"]:
print(f"{model['name']}: score={model['average_score']}, ${model['input_price']}/M in")
Compare Two Models
response = requests.get("https://benchgecko.ai/api/v1/compare", params={
"models": "gpt-5-chat,claude-opus-4-6"
})
comparison = response.json()
for model in comparison["data"]:
print(f"\n{model['name']}:")
print(f" MMLU: {model['mmlu_score']}")
print(f" HumanEval: {model['humaneval_score']}")
print(f" Price: ${model['input_price']}/M in, ${model['output_price']}/M out")
Track Price History
response = requests.get("https://benchgecko.ai/api/v1/pricing/history/gpt-4o")
history = response.json()
for entry in history["data"]:
print(f"{entry['date']}: ${entry['input_price']}/M in (provider: {entry['provider']})")
Find Open Source Alternatives
# Find the best open-source models
response = requests.get("https://benchgecko.ai/api/v1/models", params={
"open_source": True,
"sort": "score",
"order": "desc",
"limit": 10
})
print("Top 10 Open Source Models:")
for i, model in enumerate(response.json()["data"], 1):
print(f" {i}. {model['name']} ({model['provider']}): {model['average_score']} avg")
Build a Cost Estimator
def estimate_monthly_cost(model_slug, daily_input_tokens, daily_output_tokens):
response = requests.get(f"https://benchgecko.ai/api/v1/pricing/{model_slug}")
pricing = response.json()["data"]
cheapest = min(pricing, key=lambda p: p["input_price"])
monthly_in = (daily_input_tokens / 1_000_000) * cheapest["input_price"] * 30
monthly_out = (daily_output_tokens / 1_000_000) * cheapest["output_price"] * 30
return {
"provider": cheapest["provider"],
"monthly_cost": round(monthly_in + monthly_out, 2),
"input_cost": round(monthly_in, 2),
"output_cost": round(monthly_out, 2)
}
result = estimate_monthly_cost("gpt-5-chat", 50_000_000, 10_000_000)
print(f"Cheapest on {result['provider']}: ${result['monthly_cost']}/month")
Related Pages
- Getting Started -- authentication and basics
- Endpoints -- complete reference
- BenchGecko Pricing -- visual pricing tool
- BenchGecko Compare -- visual comparison
- BenchGecko Models -- browse all models