Files
hanzo.ai/app/api/models/stats/route.ts
Cursor Agentandz c3af929c56 site: one API, one account, better cheaper faster
The bar is Models, Dev, Platform, Pricing, Docs, Enterprise, Log in, and Get API key. The homepage is seven sections. Launch pages stay in the tree and drop out of the index through lib/launch.ts. /platform forwards to /cloud. Model and repository floors come from the snapshots the build already keeps.

Co-authored-by: z <[email protected]>
2026-10-26 21:53:40 +00:00

53 lines
1.5 KiB
TypeScript

import { NextResponse } from 'next/server'
import catalogue from '@/lib/data/served.json' with { type: 'json' }
export const revalidate = 3600 // Cache hourly
export async function GET() {
try {
const res = await fetch('https://api.hanzo.ai/v1/models', {
headers: { accept: 'application/json' },
next: { revalidate: 3600 },
})
if (res.ok) {
const data = await res.json()
const list = Array.isArray(data?.data) ? data.data : []
const total = list.length > 0 ? list.length : catalogue.served.length
const providers = new Set(list.map((m: any) => m.owned_by).filter(Boolean)).size || 57
return NextResponse.json(
{
totalModels: total,
count: total,
floor: Math.floor(total / 100) * 100,
label: `${Math.floor(total / 100) * 100}+`,
providers,
updated: new Date().toISOString(),
},
{
headers: {
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400',
},
},
)
}
} catch (_) {}
const fallback = catalogue.served.length
return NextResponse.json(
{
totalModels: fallback,
count: fallback,
floor: Math.floor(fallback / 100) * 100,
label: `${Math.floor(fallback / 100) * 100}+`,
providers: 57,
updated: new Date().toISOString(),
},
{
headers: {
'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate=86400',
},
},
)
}