import type { Metadata } from 'next';
import { ScrollX } from '@/components/models/scroll-x';
import Link from 'next/link';
import { Tri } from '@/components/models/badges';
import { LICENCE_DIMENSIONS } from '@/components/models/openness-block';
import { DataTable, EmptyRow, Td, Th } from '@/components/ui/data-table';
import { Hint } from '@/components/ui/hint';
import { Container, Note, PageHeader } from '@/components/ui/section';
import { Unavailable } from '@/components/ui/unavailable';
import { apiD1, safe } from '@/lib/api';
import { cn } from '@/lib/cn';
import { fmtInt, num } from '@/lib/format';
import { SITE_NAME, SITE_URL } from '@/lib/site';
export const metadata: Metadata = {
title: 'Model licences — commercial use, redistribution, derivatives, hosting restrictions',
description: 'Canonical licences of AI models (Apache-2.0, MIT, Llama Community, Gemma Terms, RAIL…): category, commercial use, redistribution, derivatives, hosting restrictions, acceptable-use policy and the number of canonical models under each — permissions read from the licence text, unknown when ambiguous.',
alternates: { canonical: '/licenses' },
openGraph: { title: `Model licences | ${SITE_NAME}`, url: `${SITE_URL}/licenses`, type: 'website' },
};
export const revalidate = 3600;
const CATEGORY_HINT: Record = {
permissive: 'OSI-style licences with no field-of-use restriction (Apache, MIT, BSD).',
copyleft: 'Derivatives must be shared under the same terms (GPL, AGPL, LGPL, MPL).',
'creative-commons': 'Creative Commons terms; NC variants forbid commercial use, ND forbids derivatives.',
'responsible-ai': 'RAIL / OpenRAIL licences: permissive with an attached acceptable-use policy.',
community: 'Vendor community licences (Llama, Gemma, Qwen, NVIDIA…): downloadable weights with user caps, hosting or field-of-use clauses.',
'research-only': 'Non-commercial / research-only terms.',
proprietary: 'No weights redistribution; access through an API or product.',
unknown: 'Stated licence text could not be classified.',
};
export default async function LicensesPage({ searchParams }: { searchParams: Promise<{ category?: string }> }) {
const { category } = await searchParams;
const res = await safe(apiD1.licenses());
const all = (res?.items ?? []).slice().sort((a, b) => (num(b.models) ?? 0) - (num(a.models) ?? 0) || a.label.localeCompare(b.label));
const items = category ? all.filter((l) => l.category === category) : all;
const cats = (res?.categories ?? []).map((c) => ({ c, n: all.filter((l) => l.category === c).length, models: all.filter((l) => l.category === c).reduce((s, l) => s + (num(l.models) ?? 0), 0) })).filter((x) => x.n > 0);
const chip = (active: boolean) => cn('inline-flex h-8 items-center gap-1.5 border px-2.5 text-xs whitespace-nowrap', active ? 'border-ink bg-ink text-canvas' : 'border-rule text-ink-2 hover:border-rule-strong hover:text-ink');
const ld = { '@context': 'https://schema.org', '@type': 'CollectionPage', name: 'Model licences', url: `${SITE_URL}/licenses`, description: metadata.description, mainEntity: { '@type': 'ItemList', numberOfItems: all.length, itemListElement: all.slice(0, 12).map((l, i) => ({ '@type': 'ListItem', position: i + 1, name: l.label, url: `${SITE_URL}/licenses/${encodeURIComponent(l.key)}` })) } };
return (
{fmtInt(items.length)}{category ? ` of ${fmtInt(all.length)}` : ''} licences
: undefined}>
{cats.length > 0 && (
All {fmtInt(all.length)}
{cats.map(({ c, n, models }) => (
{c} {fmtInt(n)}
))}
)}
{!res ? (
) : (
<>
{category && CATEGORY_HINT[category] &&
{CATEGORY_HINT[category]}
}
Licence
Category
{LICENCE_DIMENSIONS.slice(0, 5).map((d) => (
{d.label}
))}
Models
{items.length === 0 && No licence in this category. }
{items.map((l) => (
{l.label}
{l.key}
{l.spdx && l.spdx !== l.key ? ` · SPDX ${l.spdx}` : ''}
{l.osi_approved ? ' · OSI' : ''}
{l.category}
{LICENCE_DIMENSIONS.slice(0, 5).map((d) => (
))}
{num(l.models) ? (
{fmtInt(l.models)}
) : (
0
)}
))}
{res.unclassified?.length > 0 && (
Unclassified licence labels {fmtInt(res.unclassified.length)}
{res.unclassified.map((u) => (
“{u.raw}” {fmtInt(u.models)}
))}
)}
{res.note ?? 'Permissions are read from the licence text (null = the text is ambiguous). Counts cover canonical models only.'} Hosting restrictions / acceptable-use: “Yes — restricted” means the clause exists.
{LICENCE_DIMENSIONS.map((d) => (
{d.label}
{d.hint}
))}
>
)}
);
}