#!/usr/bin/env node /** * @file scripts/generate-provider-table.mjs * @description Generate docs/providers.md from sources.js so the provider table can never drift. * * @description * WHY: the old README hand-listed all 24 providers with per-provider model counts. * Those counts drifted every time the catalog changed (16 of 24 were wrong at audit * time). This script derives the table straight from `sources.js`, the same data the * TUI, the web dashboard and the router read, so the doc and the app can never * disagree. Re-run it after any catalog change and commit the result. * * HOW: it imports sources.js (no network, no eval of remote data), counts live * models per provider (skipping models whose `deprecatedAfter` date has passed, * exactly like the `MODELS` flatten in sources.js), finds each provider's best * tier, and renders a markdown table sorted by live model count (desc, ties broken * by provider key so output is byte-stable). Free-tier wording comes from the * `quota` field, env var names come from ENV_VAR_NAMES in * src/core/provider-metadata.js, and signup links come from PROVIDER_METADATA. * * @functions * - main() -> reads sources.js + provider-metadata.js, writes docs/providers.md, prints a summary * * @exports (none, CLI script) * * @usage * node scripts/generate-provider-table.mjs * * @see sources.js - the provider catalog (single source of truth) * @see src/core/provider-metadata.js - ENV_VAR_NAMES + PROVIDER_METADATA (labels, env vars, signup URLs) * @see docs/providers.md - generated output, linked from README.md */ import { writeFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' import path from 'node:path' const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') const OUT = path.join(root, 'docs', 'providers.md') // 📖 Tier ordering, best (S+) first. Anything unknown sorts last. const TIER_RANK = { 'S+': 0, S: 1, 'A+': 2, A: 3, 'A-': 4, 'B+': 5, B: 6, C: 7 } const { sources } = await import(path.join(root, 'sources.js')) const { ENV_VAR_NAMES, PROVIDER_METADATA } = await import(path.join(root, 'src/core/provider-metadata.js')) // 📖 Same deprecation rule as the MODELS flatten in sources.js: a model whose // 📖 deprecatedAfter date (index 6) is past is excluded from the live count. const today = new Date().toISOString().split('T')[0] const rows = Object.entries(sources) .map(([key, src]) => { const live = (src.models || []).filter((m) => !(m[6] && today > m[6])) const bestTier = live .map((m) => String(m[2] || 'C')) .reduce((best, t) => ((TIER_RANK[t] ?? 99) < (TIER_RANK[best] ?? 99) ? t : best), 'C') const meta = PROVIDER_METADATA[key] || {} return { key, name: src.name || key, count: live.length, bestTier, quota: src.quota || 'see provider site', envVar: ENV_VAR_NAMES[key] || null, signupUrl: meta.signupUrl || null, } }) // 📖 Deterministic order: live model count desc, then provider key asc. .sort((a, b) => b.count - a.count || a.key.localeCompare(b.key)) const totalModels = rows.reduce((sum, r) => sum + r.count, 0) const esc = (s) => String(s).replace(/\|/g, '\\|') const tableLines = [ '| Provider | Live models | Best tier | Free tier | Env var |', '|----------|-------------|-----------|-----------|---------|', ...rows.map((r) => { const name = r.signupUrl ? `[${esc(r.name)}](${r.signupUrl})` : esc(r.name) const env = r.envVar ? `\`${r.envVar}\`` : 'none (keyless)' return `| ${name} | ${r.count} | ${r.bestTier} | ${esc(r.quota)} | ${env} |` }), ] const md = ` # Provider Catalog **${rows.length} providers / ${totalModels} live models**, generated from [\`sources.js\`](../sources.js), the same catalog the TUI, the Web Dashboard and the Smart Model Router read. Counts update only when this script is re-run, so they always match the shipped catalog. Sign up on any one provider to grab a free API key: **one key is enough to start**. Add more at any time from inside the app (press \`P\` in the TUI, or the Web Dashboard Settings page). A few providers (\`Kilo\`, \`LLM7\`, OVHcloud sandbox) even answer without a key, with tighter shared limits. ## What does "free" mean here? **Free is a property of the (provider, model) pair, never of the provider as a whole.** Almost every provider listed below also sells paid access to bigger or faster models on the same account; those are deliberately excluded. A row appears in this catalog only when that exact model id costs **$0 to call through that specific provider**, verified live against its \`/v1/models\` or pricing endpoint at audit time. The same open-weights model can be free on one host and paid on another: \`google/gemma-4-31b-it\` costs nothing on Requesty (zero-price entry, 200 req/day free tier) while other hosts charge per token for the very same weights. That is why the catalog is organized per provider and model id, not per model name. The $0 access comes in three shapes, surfaced as the quota badge on every provider (same colors as the Web Dashboard): | Badge | Meaning | Examples | |-------|---------|----------| | **Free** | Recurring free access: rate-limited or daily-capped, but it does not run out and never asks for a card | NVIDIA 1000 req/month, Groq RPM caps, Mistral Experiment plan, Kilo keyless, Requesty 200 req/day, Ollama Cloud free plan | | **Limited** | Free allowance that depletes or needs unlocking: one-off credits, expiring token grants, or capped free requests | Scaleway 1M tokens, Qwen 1M tokens/model, Vercel $5 credits/30 days, OpenRouter 50 req/day (1000 after a $10 credit), Cloudflare 10k neurons/day | | **Metered** | Pay-per-token passthrough gateway where only explicitly $0-priced models are listed; no provider currently carries this badge | (none today) | Two caveats worth knowing: free tiers get smaller or disappear over time (the audit log in [\`sources.js\`](../sources.js) tracks every removal), and rate limits are per account, so "free" means free of charge, not unlimited. ## All providers (sorted by live model count) ${tableLines.join('\n')} ## Tier scale Every model is tiered by its **SWE-bench Verified** score, the industry-standard benchmark for real coding tasks. | Tier | SWE-bench | Best for | |------|-----------|----------| | **S+** | 70%+ | Elite frontier coders, complex refactors | | **S** | 60-70% | Most coding tasks, strong general use | | **A+** | 50-60% | Great alternatives | | **A** | 40-50% | Solid everyday models | | **A-** | 35-40% | Decent for smaller tasks | | **B+** | 30-35% | Average, constrained infra | | **B** | 20-30% | Below average, edge setups | | **C** | <20% | Lightweight / completion only | ## Provider notes - **Cloudflare AI**: Cloudflare's OpenAI-compatible endpoint is **account-scoped** (\`/client/v4/accounts/{account_id}/ai/v1/chat/completions\`), so the raw catalog URL cannot work on its own (it 404s for every model, issue #181). free-coding-models resolves the account id automatically on every request path: 1) the \`CLOUDFLARE_ACCOUNT_ID\` env var, 2) the id stored in the config (\`settings.cloudflareAccountId\`), or 3) zero-setup auto-discovery: a one-time \`GET /client/v4/accounts\` call with your Cloudflare API key whose first account id is cached and persisted. With just an API key, everything works out of the box. - **Pollinations Pollen**: Pollinations meters usage in **Pollen** (roughly 1 Pollen = 1 USD). You receive free Pollen every day via quests (star the \`pollinations/pollinations\` repo, help on an issue) depending on your seed/flower/nectar tier. If your balance shows \`0.0000\` on enter.pollinations.ai, every cache MISS returns \`402 PAYMENT_REQUIRED\` and the ping shows \`402\`. A Cloudflare cache HIT can still pass with 0 Pollen but is not reliable. Check your balance under enter.pollinations.ai -> API Keys, complete a quest, and wait for the daily grant at midnight UTC. The integration stays experimental; the Pollen system can change. - **SiliconFlow & Requesty**: verified 2026-08-24 against live \`/v1/models\` endpoints and official docs, recurring free tiers confirmed. - **OpenCode Zen**: free models exclusive to the OpenCode ecosystem (OpenAI-compatible endpoint, so other tools work too). Sign up at [opencode.ai/auth](https://opencode.ai/auth), enter the Zen key via \`P\`, and Zen models appear in the main table. Since 2026-09-07 the Zen gateway requires an \`x-opencode-session\` header on every request (without it, calls fail with HTTP 400 \`MissingSessionID\`); free-coding-models sends a stable per-process session uuid automatically on every probe, benchmark and router call, so no extra setup is needed. - **NVIDIA NIM** is the biggest no-credit-card provider by free quota (~40 RPM). **Cerebras** has the lowest latency in the catalog. **Groq** is the fastest sign-up. ## Providers removed from the catalog (and why) \`iFlow\` shut down on April 17, 2026. \`Together AI\`, \`Perplexity API\`, \`DeepInfra\`, \`Replicate\`, \`Fireworks\`, \`Hyperbolic\`, \`Hugging Face\`, \`SiliconFlow\` (later re-added), \`Chutes AI\` were removed because they are paid, trial-credit only, too tiny to be useful, unclear as a stable free API, or tool-specific rather than a generally usable free provider. \`Rovo\` and \`Gemini CLI\` were removed as tool integrations (CLI-only, not generally usable free providers). Providers kept outside the core catalog live in [resources.md](./resources.md). ` writeFileSync(OUT, md, 'utf8') // 📖 Console summary: the top-8 rows are pasted into README.md's compact table, // so print them ready to copy (plus the headline numbers). const top8 = rows.slice(0, 8) .map((r) => `| [${esc(r.name)}](${r.signupUrl || ''}) | ${r.count} | ${r.bestTier} | \`${r.envVar}\` |`) .join('\n') console.log(`docs/providers.md written: ${rows.length} providers / ${totalModels} live models`) console.log('') console.log('README top-8 rows (paste into the Providers section):') console.log('| Provider | Models | Best tier | Env var |') console.log('|----------|--------|-----------|---------|') console.log(top8)