Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(llm): widen the free failover chain with six more provider rungs
nirholas296e5e731834
diff --git a/.env.example b/.env.exampleindex eef6f5b2d..46ce0c6b6 100644--- a/.env.example+++ b/.env.example@@ -103,6 +103,32 @@ GROQ_API_KEY=# containers (nvcr.io) — not used here. Same secret value, different name/path.NVIDIA_API_KEY=+# SambaNova Cloud (free tier, no card): Llama 3.3 70B on its own free quota+# pool (about 20 req/min, 200K tokens/day per model). Optional rung in the+# shared LLM chain (api/_lib/llm.js). Sign up at https://cloud.sambanova.ai+SAMBANOVA_API_KEY=++# Mistral Experiment tier (free, no card): about 1B tokens/month at 1 req/sec+# in exchange for opting the account into data training. The largest free+# quota in the shared LLM chain. Get a key at https://console.mistral.ai+MISTRAL_API_KEY=++# Z.AI (Zhipu) key: permanently free, rate-limited GLM Flash models+# (glm-4.7-flash) on an OpenAI-compatible endpoint. Optional rung in the+# shared LLM chain. Sign up at https://z.ai, docs at https://docs.z.ai+ZAI_API_KEY=++# SiliconFlow international (free tier): Qwen3 8B step-down rung near the end+# of the free section of the shared LLM chain. Get a key at+# https://siliconflow.com+SILICONFLOW_API_KEY=++# Cloudflare Workers AI (free tier, 10,000 neurons/day): 70B-class Llama at+# the edge. The rung needs BOTH values; the OpenAI-compatible URL embeds the+# account id. Create a Workers AI scoped token at https://dash.cloudflare.com+CLOUDFLARE_ACCOUNT_ID=+CLOUDFLARE_AI_API_TOKEN=+# OpenAI — used for gpt-4o-mini fallback. Get a key at https://platform.openai.comOPENAI_API_KEY=diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex 936cf814d..f8965ca52 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -602,7 +602,7 @@ Representative endpoints:| `POST /api/chat` | Avatar chat endpoint: memory recall, tool dispatch, Guardian governance || `POST /api/llm/anthropic` | We-pay proxy for Anthropic Claude (embed contexts, free tier) |-**Provider failover in `/api/chat`:** Groq → OpenRouter → NVIDIA NIM → Anthropic → OpenAI → watsonx/Orchestrate+**Provider failover in `/api/chat`:** Groq → OpenRouter → NVIDIA NIM → SambaNova → Mistral → Z.AI → Anthropic → OpenAI → watsonx/Orchestrate (plus the Vertex Gemini anchor appended at the tail)#### Voice & Multimodal (`api/tts/`, `api/asr.js`, `api/a2f.js`, `api/vision.js`)@@ -1897,6 +1897,11 @@ Stores: GLBs · audio clips · thumbnails · manifests · OG images · validatio| `NVIDIA_API_KEY` | required | NVIDIA NIM (Magpie, Riva, A2F, free LLMs) || `WATSONX_API_KEY` + `WATSONX_PROJECT_ID` | required | IBM watsonx.ai Granite || `GROQ_API_KEY` | required | Groq fast inference (free tier primary) |+| `SAMBANOVA_API_KEY` | optional | SambaNova Cloud free tier (Llama 3.3 70B rung) |+| `MISTRAL_API_KEY` | optional | Mistral Experiment tier (about 1B free tokens/month) |+| `ZAI_API_KEY` | optional | Z.AI free GLM Flash rung |+| `SILICONFLOW_API_KEY` | optional | SiliconFlow free-tier Qwen3 8B step-down rung |+| `CLOUDFLARE_ACCOUNT_ID` + `CLOUDFLARE_AI_API_TOKEN` | optional | Cloudflare Workers AI free rung (10k neurons/day) || `PUMPFUN_BOT_URL` | required | pump.fun indexer backend || `THREEWS_SOL_PARENT_SECRET_BASE58` | required | SNS subdomain minting keypair || `THREE_TREASURY_WALLET` + `THREE_REWARDS_WALLET` | required | $THREE token distribution |@@ -3330,7 +3335,7 @@ Tiers: **CRITICAL** = `req()` in `api/_lib/env.js` (cold-start throw) or prod-fa- **Solana / on-chain:** `SOLANA_RPC_URL` (+aliases `SOLANA_RPC`/`SOLANA_MAINNET_RPC`/`NEXT_PUBLIC_SOLANA_RPC_URL`), `SOLANA_RPC_URL_DEVNET`/`SOLANA_DEVNET_RPC`, `SOLANA_RPC_URLS`/`_FALLBACK_URLS`, `HELIUS_API_KEY`/`HELIUS_WEBHOOK_AUTH`, `SOLANA_USDC_MINT`/`DEVNET_USDC_MINT`, `NEXT_PUBLIC_SOLANA_ALT_ADDRESS`, `TREASURY_KEYPAIR`/`PLATFORM_TREASURY_KEYPAIR`, `MAINNET_RPC_URL`, `JITO_BLOCK_ENGINE_URL`/`JITO_BUNDLE_URL`/`JITO_TIP_SOL`, `ALCHEMY_API_KEY`/`ANKR_API_KEY`/`DRPC_API_KEY`, `SOLANA_AGENT_COLLECTION_MAINNET`/`_DEVNET`/`_AUTHORITY_KEY`, `THREEWS_SOL_PARENT_DOMAIN`/`_PARENT_SECRET_BASE58`, `STOREFRONT_ORIGIN`, `BUBBLEGUM_MERKLE_TREE`/`_TREE_AUTHORITY`, `NFT_STORAGE_TOKEN`/`WEB3_STORAGE_TOKEN`/`PINATA_JWT`/`FILEBASE_KEY`/`_SECRET`, `BTC_INSCRIPTION_RECEIVE_ADDRESS`/`ORDINALSBOT_API_KEY`/`_BASE_URL`, `AGENC_RPC_URL`/`AGENC_DEVNET_RPC_URL`/`AGENC_BRIDGE_URL`.- **EVM / x402:** `AGENT_RELAYER_ADDRESS`, `PERMISSIONS_RELAYER_ENABLED`, `BASE_RPC_URL`/`BASE_SEPOLIA_RPC_URL`/`SEPOLIA_RPC_URL`, `RPC_URL_<CHAINID>`, `EVM_RPC_URL`, `EVM_PRIVATE_KEY`/`EVM_TREASURY_PRIVATE_KEY`/`PRIVATE_KEY`, `EVM_MIN_CONFIRMATIONS`, `X402_ASSET_MINT_SOLANA`/`X402_ASSET_ADDRESS_BASE`/`_ARBITRUM`/`_BSC`, `X402_MAX_AMOUNT_REQUIRED`, `X402_IDEMPOTENCY_TTL_SECONDS`, `X402_FACILITATOR_URL_SOLANA`/`_BASE`/`_TOKEN_*`/`_TIMEOUT_MS`, `CDP_API_KEY_ID`/`_SECRET`, `X402_CDP_FACILITATOR_URL`, `X402_ACCEPT_THREE_SOLANA`/`X402_THREE_AMOUNT_SOLANA`, `X402_EVM_NETWORKS`, `X402_BUILDER_CODE_APP`/`_WALLET`, `X402_MAX_PER_CALL_ATOMIC`/`_PER_HOUR_ATOMIC`/`_PER_DAY_ATOMIC`, `INTERNAL_API_KEY`, `OFFER_RECEIPT_SIGNING_PRIVATE_KEY`/`_FORMAT`/`_JWK`/`_JWS_ALG`, `SERVER_DOMAIN`, `A2A_MANDATE_SECRET`, `A2A_PAYER_PRIVATE_KEY`/`A2A_PAYER_SOLANA_SECRET`, `A2A_REPUTATION_RPC_URL`, `VALIDATOR_PRIVATE_KEY`, `ETHERSCAN_API_KEY`/`BASESCAN_API_KEY`, `ERC8004_CRAWL_LOOKBACK`, `SPLITS_SIGNER_PRIVATE_KEY`, `MARKETPLACE_PAYER_KEYPAIR`/`MARKETPLACE_PLATFORM_FEE_BPS`/`_WALLET`, `ZAUTH_API_KEY`/`_DEBUG`/`_API_ENDPOINT`/`_SCAN_URL`/`_CIRCUIT_*`/`_REFUND_*`.- **MCP / bridge:** `MCP_RESOURCE`, `MCP_REGISTRY_TOKEN`, `MCP_AGENT_TALK_ENDPOINT`, `MCP_POSE_PREVIEW_BASE`, `MCP_SVM_PAYMENT_ADDRESS`, `MCP_VANITY_PRICE_USD`, `MCP_BRIDGE_EVM_PRIVATE_KEY`/`_SVM_PRIVATE_KEY`, `MCP_BRIDGE_ALLOWED_HOSTS`/`_ALLOWED_PAYTO`/`_ALLOW_HTTP`, `MCP_BRIDGE_BAZAAR_URL`/`_DISCOVER_LIMIT`, `MCP_BRIDGE_MAX_DEPOSIT_ATOMIC`/`_MAX_PRICE_PER_CALL_ATOMIC`/`_MAX_TOTAL_ATOMIC`, `X402_BRIDGE_PORT`/`_ALLOWED_ENDPOINT_ORIGINS`/`_MAX_USDC_MICROS`.-- **LLM providers:** `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`/`OPENAI_BASE_URL`, `GROQ_API_KEY`, `NVIDIA_API_KEY`, `OPENROUTER_API_KEY`/`OPENROUTER_FALLBACK_KEYS`, `DASHSCOPE_API_KEY`, `MODELSCOPE_API_KEY`, `GEMINI_API_KEY`/`GOOGLE_API_KEY`/`GOOGLE_GENAI_API_KEY`/`GOOGLE_CLOUD_PROJECT`, `WATSONX_API_KEY`/`_PROJECT_ID`/`_SPACE_ID`/`_URL`/`_MODEL_ID`/`_API_VERSION`/`_GUARDIAN_MODEL_ID`/`_VISION_MODEL_ID`/`_ORCHESTRATE_*`, `GUARDIAN_SEND_CAP_USD`/`GUARDIAN_DISABLE`, `LIVEPEER_API_KEY`, `LONGCAT_WORKER_URL`/`_KEY`, `OMNI_URL`/`NIM_URL`, `CHAT_MODEL`/`CHAT_MAX_TOKENS`/`CHAT_URL`, `KNOWLEDGE_RERANK_ENABLED`, `ANON_MODERATION_DISABLED`/`_MODEL`/`_TIMEOUT_MS`, `VOYAGE_API_KEY`, `BRAVE_API_KEY`, `TAVILY_API_KEY`/`EXA_API_KEY`/`SERPER_API_KEY`/`SERPAPI_API_KEY`, `BIRDEYE_API_KEY`/`GMGN_COOKIE`, `NEYNAR_API_KEY`, `TWITTER_BEARER_TOKEN`/`X_API_BEARER`, `AIXBT_API_KEY`/`_API_BASE`.+- **LLM providers:** `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`/`OPENAI_BASE_URL`, `GROQ_API_KEY`, `NVIDIA_API_KEY`, `OPENROUTER_API_KEY`/`OPENROUTER_FALLBACK_KEYS`, `SAMBANOVA_API_KEY`, `MISTRAL_API_KEY`, `ZAI_API_KEY`, `SILICONFLOW_API_KEY`, `CLOUDFLARE_ACCOUNT_ID`/`CLOUDFLARE_AI_API_TOKEN`, `DASHSCOPE_API_KEY`, `MODELSCOPE_API_KEY`, `GEMINI_API_KEY`/`GOOGLE_API_KEY`/`GOOGLE_GENAI_API_KEY`/`GOOGLE_CLOUD_PROJECT`, `WATSONX_API_KEY`/`_PROJECT_ID`/`_SPACE_ID`/`_URL`/`_MODEL_ID`/`_API_VERSION`/`_GUARDIAN_MODEL_ID`/`_VISION_MODEL_ID`/`_ORCHESTRATE_*`, `GUARDIAN_SEND_CAP_USD`/`GUARDIAN_DISABLE`, `LIVEPEER_API_KEY`, `LONGCAT_WORKER_URL`/`_KEY`, `OMNI_URL`/`NIM_URL`, `CHAT_MODEL`/`CHAT_MAX_TOKENS`/`CHAT_URL`, `KNOWLEDGE_RERANK_ENABLED`, `ANON_MODERATION_DISABLED`/`_MODEL`/`_TIMEOUT_MS`, `VOYAGE_API_KEY`, `BRAVE_API_KEY`, `TAVILY_API_KEY`/`EXA_API_KEY`/`SERPER_API_KEY`/`SERPAPI_API_KEY`, `BIRDEYE_API_KEY`/`GMGN_COOKIE`, `NEYNAR_API_KEY`, `TWITTER_BEARER_TOKEN`/`X_API_BEARER`, `AIXBT_API_KEY`/`_API_BASE`.- **Voice / 3D gen:** `ELEVENLABS_API_KEY`, `NVIDIA_ASR_FUNCTION_ID`/`NVIDIA_A2F_FUNCTION_ID`/`NVIDIA_COSMOS_INVOKE_URL`, `LIVEKIT_API_KEY`/`_SECRET`/`_SERVER_URL`, `GCP_PROJECT`/`GCP_REGION`/`GCP_SERVICE_ACCOUNT_JSON`, `GCP_RECONSTRUCTION_URL`/`_KEY`, `GCP_TRIPOSG_URL`/`GCP_HUNYUAN3D_URL`/`GCP_REMESH_URL`/`GCP_TEXTURE_URL`/`GCP_STYLIZE_URL`/`GCP_SEGMENT_URL`/`GCP_REMBG_URL`/`GCP_TEXT2MOTION_URL`, `HF_TOKEN`/`HF_RECONSTRUCT_SPACE(S)`, `REPLICATE_API_TOKEN`/`_RECONSTRUCT_MODEL`/`_RERIG_MODEL`/`_POLL_MS`/`_TIMEOUT_MS`/`_WEBHOOK_URL`/`_WEBHOOK_SIGNING_KEY`, `NIM_TRELLIS_URL`/`_KEY`/`MODEL_TRELLIS_URL`, `TRIPO_MODEL_VERSION`, `VERTEX_IMAGEN_MODEL`, `CHROMIUM_PACK_URL`/`CHROME_PATH`/`PUPPETEER_EXECUTABLE_PATH`, `AVATURN_API_KEY`/`_API_URL`/`_SEED_ENABLED`, `MIXAMO_TOKEN`, `AVATAR_REGEN_PROVIDER`, `AUTO_RIG_DAILY_PER_USER`/`_GLOBAL_HOURLY`/`_PRIVATE`/`_REQUIRE_TIER`, `FORGE_ORIGIN`/`FORGE_PREFER_FREE`/`FORGE_FREE_POLL_MS`/`FORGE_PAID_GLOBAL_HOURLY`.- **Pump.fun / $THREE / treasury:** `PUMP_X402_LAUNCHER_SECRET_KEY_B64`, `PUMP_CRON_RELAYER_SECRET_KEY_B64`, `PUMP_DEFAULT_AGENT_MINT`/`_NETWORK`, `PUMP_PLATFORM_FEE_BPS`/`_WALLET`, `PUMP_GRADUATIONS_SOURCE`/`GRADUATIONS_LIST_KEY`/`_MAX_LEN`, `PUMPFUN_BOT_TOKEN`/`_URL`/`PUMPFUN_MCP_URL`, `PUMP_COINS_V2_BASE`/`PUMP_FRONTEND_BASE`, `PUMPKIT_WEBHOOK_SECRET`, `THREE_WS_MARK_ENFORCE`/`ALLOW_UNMARKED_MINT`, `THREE_TOKEN_MINT`/`THREE_MINT`/`THREE_TOKEN_DECIMALS`, `THREE_PRIZE_PAYOUT_KEY`, `THREE_BURN_ADDRESS`, `THREE_QUOTE_TTL_S`, `THREE_ALLOWANCE_DELEGATE_SECRET_KEY_B64`, `THREE_BUYBACK_ENABLED`/`_SECRET_KEY_B64`/`_MIN_USD`/`_MAX_USD`/`_COMMIT_BPS`/`_SLIPPAGE_BPS`, `BUYBACK_BPS`, `PLATFORM_FEE_BPS`, `REWARDS_DISTRIBUTOR_SECRET`, `REFLECTION_DAILY_CAP`/`_DEBOUNCE_MS`/`REFLECT_SWEEP_BATCH`, `REFERRAL_COMMISSION_BPS`, `RIDER_VAULT_ADDRESS`/`_HELIUS_WEBHOOK_SECRET`, `CREDITS_DEPOSIT_WALLET_SOLANA`, `PURCHASE_RECEIPT_KEY`, `VANITY_SERVICE_KEY`/`VANITY_BOUNTY_PAYOUT_KEY`/`VANITY_DROP_FUNDING_KEY`, `COIN_TREASURY_SECRET_KEY_B64`, `COSMETIC_SPLIT_TREASURY_SECRET_KEY_B64`, `CLUB_SOLANA_TREASURY_SECRET_KEY_B64`/`CLUB_EVM_TREASURY_PRIVATE_KEY`/`CLUB_BASE_RPC_URL`/`CLUB_SWEEP_DUST_ATOMICS`.- **Comms / observability:** `TELEGRAM_BOT_TOKEN`/`TELEGRAM_CHANGELOG_CHAT_ID`/`_ALERTS_CHAT_ID`/`_ORACLE_CHAT_ID`/`_SNIPER_CHAT_ID`, `RESEND_API_KEY`/`_AUDIENCE_ID`, `EMAIL_FROM`/`_REPLY_TO`, `SENTRY_DSN`/`_ENVIRONMENT`/`_RELEASE`, `AXIOM_TOKEN`/`_DATASET`/`_URL`, `VAPID_PUBLIC_KEY`/`_PRIVATE_KEY`/`_SUBJECT`, `DEV_TO_API_KEY`, `MEDIUM_INTEGRATION_TOKEN`/`_AUTHOR_ID`, `THREEWS_TWITTER_URL`.@@ -3379,7 +3384,7 @@ Tiers: **CRITICAL** = `req()` in `api/_lib/env.js` (cold-start throw) or prod-fa**10. Granite Guardian gate (`api/_lib/granite-guardian.js`).** 12-risk taxonomy, each an independent watsonx classifier pass; default input risks `[jailbreak,harm,violence,unethical_behavior,social_bias]` run concurrently. Each pass recovers a real unsafe-probability by softmaxing Yes/No logprobs (`logprobs:true, top_logprobs:5`); `decide` → allow/review/block at `FLAG_THRESHOLD=0.55`. `governSend` adds a model-independent `sendCapUsd` (default $25). **Hash-chained audit:** stores only SHA-256 of content + decision + `prev` hash; `verifyAuditChain` re-derives from `GENESIS_HASH`.-**11. LLM failover (`api/_lib/chat-models.js`, `api/chat.js`).** `DEFAULT_PROVIDER_ORDER = [groq, openrouter, nvidia, anthropic, openai]` — free lanes first, paid as last-resort backstop (prod paid keys routinely 401/over-quota). `MODEL_CATALOG` annotates `{provider, tools, moderationGated}`; `usableModels` drops tool-incapable or moderation-gated models from auto-chains. `api/chat.js` skips providers in health cooldown (recent 429/5xx/timeout) + unconfigured keys, bounds the loop by `TOTAL_BUDGET_MS=25000` + `MAX_FALLBACK_ATTEMPTS=4` (per-call abort at `min(15000, remaining)`); auth/billing failures cool the whole provider; exhausted-within-budget → clean **503 + Retry-After:20**.+**11. LLM failover (`api/_lib/chat-models.js`, `api/chat.js`).** `DEFAULT_PROVIDER_ORDER = [groq, openrouter, nvidia, sambanova, mistral, zai, anthropic, openai, grok]`: free lanes first, paid as last-resort backstop (prod paid keys routinely 401/over-quota). The shared utility chain (`api/_lib/llm.js providerChain()`) is wider still: groq → cerebras → openrouter `:free` → nvidia → sambanova → mistral → zai → cloudflare (Workers AI) → ovh (keyless) → gemini → vertex-gemini (anchor) → pollinations (keyless) → llm7 (keyless) → siliconflow → groq#instant → paid tail; every keyed free rung is skipped when its env var is unset, and the three keyless rungs (OVH, Pollinations, LLM7) are unconditional. `MODEL_CATALOG` annotates `{provider, tools, moderationGated}`; `usableModels` drops tool-incapable or moderation-gated models from auto-chains. `api/chat.js` skips providers in health cooldown (recent 429/5xx/timeout) + unconfigured keys, bounds the loop by `TOTAL_BUDGET_MS=25000` + `MAX_FALLBACK_ATTEMPTS=4` (per-call abort at `min(15000, remaining)`); auth/billing failures cool the whole provider; exhausted-within-budget → clean **503 + Retry-After:20**.### Specifications, Protocols & Platform Constantsdiff --git a/api/_lib/chat-models.js b/api/_lib/chat-models.jsindex 65db6bada..dda681bb2 100644--- a/api/_lib/chat-models.js+++ b/api/_lib/chat-models.js@@ -106,6 +106,15 @@ export const MODEL_CATALOG = {'meta/llama-3.3-70b-instruct': { provider: 'nvidia', tools: true },'nvidia/llama-3.3-nemotron-super-49b-v1.5': { provider: 'nvidia', tools: true },+ // ── SambaNova Cloud free tier (no card): Llama 3.3 70B, own quota pool ────+ 'Meta-Llama-3.3-70B-Instruct': { provider: 'sambanova', tools: true },++ // ── Mistral Experiment tier: about 1B free tokens/month ───────────────────+ 'mistral-small-latest': { provider: 'mistral', tools: true },++ // ── Z.AI (Zhipu): permanently free, rate-limited GLM Flash lane ───────────+ 'glm-4.7-flash': { provider: 'zai', tools: true },+// ── xAI Grok (paid; host or BYOK key) — OpenAI-compatible at api.x.ai ─────'grok-4.5': { provider: 'grok', tools: true },'grok-4.3': { provider: 'grok', tools: true },@@ -290,6 +299,9 @@ export const PROVIDER_MODEL_DEFAULTS = {openrouter: DEFAULT_FREE_MODEL,groq: 'llama-3.3-70b-versatile',nvidia: 'meta/llama-3.3-70b-instruct',+ sambanova: 'Meta-Llama-3.3-70B-Instruct',+ mistral: 'mistral-small-latest',+ zai: 'glm-4.7-flash',openai: 'gpt-5.4-nano',grok: 'grok-4.5',};@@ -305,16 +317,22 @@ export const PROVIDER_MODEL_DEFAULTS = {* DEFAULT_FREE_MODEL), multi-key rotation in llm.js.* 3. nvidia — NVIDIA NIM free tier; an independent third lane on a* different account/infra than the first two.- * 4. anthropic — paid backstop; only reached when every free lane failed- * (and currently 401s in prod — see operational note).- * 5. openai — paid backstop; account over quota (see operational note).- * 6. grok — paid backstop (xAI); usually reached only via an explicit+ * 4. sambanova - SambaNova Cloud free tier; the same Llama 3.3 70B on a+ * fourth independent quota pool.+ * 5. mistral - Mistral Experiment tier; the largest free quota in the+ * ladder (about 1B tokens/month).+ * 6. zai - Z.AI's permanently free GLM Flash lane; a sixth+ * independent free quota pool.+ * 7. anthropic - paid backstop; only reached when every free lane failed+ * (and currently 401s in prod, see operational note).+ * 8. openai - paid backstop; account over quota (see operational note).+ * 9. grok - paid backstop (xAI); usually reached only via an explicit* provider/model request or a BYOK key.* Providers without a configured key are skipped, so the effective ladder is* short in the common case. A provider in a health cooldown (see* api/_lib/provider-health.js) is also skipped for the cooldown window.*/-export const DEFAULT_PROVIDER_ORDER = ['groq', 'openrouter', 'nvidia', 'anthropic', 'openai', 'grok'];+export const DEFAULT_PROVIDER_ORDER = ['groq', 'openrouter', 'nvidia', 'sambanova', 'mistral', 'zai', 'anthropic', 'openai', 'grok'];/*** OpenRouter sibling models for per-model rate-limit failover. OpenRouter's@@ -330,15 +348,15 @@ export const OPENROUTER_SIBLINGS = [];/**- * Providers an anonymous (unauthenticated) caller may use. The first three are- * third-party free tiers; when all of them are rate-limited an anon request+ * Providers an anonymous (unauthenticated) caller may use. All but the last+ * are third-party free tiers; when all of them are rate-limited an anon request* would otherwise 503, so `vertex-gemini` (the credits-funded Vertex anchor,* effectively free to the user and the only rung with no third-party quota to* exhaust) is included as the last-resort anchor. Its rung carries its own* fixed model, so it is never auto-selected as an initial route — it is only* reached via failover once the free tiers are exhausted.*/-export const ANON_PROVIDER_LIST = ['groq', 'openrouter', 'nvidia', 'vertex-gemini'];+export const ANON_PROVIDER_LIST = ['groq', 'openrouter', 'nvidia', 'sambanova', 'mistral', 'zai', 'vertex-gemini'];/*** Bounds on the fallback chain so a single request can't churn through everydiff --git a/api/_lib/env.js b/api/_lib/env.jsindex 594efc71e..9c63ea315 100644--- a/api/_lib/env.js+++ b/api/_lib/env.js@@ -579,6 +579,51 @@ export const env = {return opt('GEMINI_API_KEY');},+ // SambaNova Cloud key (cloud.sambanova.ai) - free-tier OpenAI-compatible+ // Llama 3.3 70B inference on its own quota pool (about 20 req/min and 200K+ // tokens/day per model, no card required). Optional rung in the shared LLM+ // chain; skipped when unset.+ get SAMBANOVA_API_KEY() {+ return opt('SAMBANOVA_API_KEY');+ },++ // Mistral Experiment-tier key (console.mistral.ai) - the largest free+ // quota in the chain (about 1B tokens/month at 1 req/sec). The Experiment+ // plan requires opting the account into data training; this chain carries+ // platform utility prompts, not user secrets. Optional rung; skipped when+ // unset.+ get MISTRAL_API_KEY() {+ return opt('MISTRAL_API_KEY');+ },++ // Z.AI (Zhipu) key (z.ai, docs.z.ai) - permanently free, rate-limited GLM+ // Flash models on an OpenAI-compatible endpoint (api.z.ai/api/paas/v4).+ // Optional rung in the shared LLM chain; skipped when unset.+ get ZAI_API_KEY() {+ return opt('ZAI_API_KEY');+ },++ // SiliconFlow key (siliconflow.com international) - free-tier Qwen3 8B on+ // an OpenAI-compatible endpoint. A capability step-down rung near the end+ // of the free section; skipped when unset.+ get SILICONFLOW_API_KEY() {+ return opt('SILICONFLOW_API_KEY');+ },++ // Cloudflare account id for Workers AI (dash.cloudflare.com). The Workers+ // AI OpenAI-compatible URL embeds the account id, so the LLM rung needs+ // this AND CLOUDFLARE_AI_API_TOKEN; with either half missing the rung is+ // skipped.+ get CLOUDFLARE_ACCOUNT_ID() {+ return opt('CLOUDFLARE_ACCOUNT_ID');+ },++ // Cloudflare API token scoped to Workers AI (10,000 free neurons/day).+ // Pairs with CLOUDFLARE_ACCOUNT_ID above.+ get CLOUDFLARE_AI_API_TOKEN() {+ return opt('CLOUDFLARE_AI_API_TOKEN');+ },+// NVIDIA NIM API key (build.nvidia.com) — free OpenAI-compatible inference for// 100+ hosted models (Nemotron, DeepSeek, Kimi, GLM, Llama 4, Qwen). Used by// brain/chat as selectable native providers and by the embed we-pay proxydiff --git a/api/_lib/llm-pricing.js b/api/_lib/llm-pricing.jsindex b4ee9f273..6283e7fdb 100644--- a/api/_lib/llm-pricing.js+++ b/api/_lib/llm-pricing.js@@ -81,7 +81,20 @@ const PRICE_PER_MTOK = {// it draws down GCP credits. openrouter is deliberately NOT here either: the// platform key serves both `:free` models and paid vendor mirrors, so freeness// is a property of the MODEL on that lane, not of the lane (see isFreeLane).-const FREE_PROVIDERS = new Set(['groq', 'nvidia', 'cerebras', 'gemini', 'ovh', 'pollinations']);+const FREE_PROVIDERS = new Set([+ 'groq',+ 'nvidia',+ 'cerebras',+ 'gemini',+ 'ovh',+ 'pollinations',+ 'sambanova',+ 'mistral',+ 'zai',+ 'cloudflare',+ 'siliconflow',+ 'llm7',+]);// Strip a rung suffix from a provider name: '#n' for multi-key rungs// (openrouter#2), ':variant' for same-key model variants, '#instant' for thediff --git a/api/_lib/llm.js b/api/_lib/llm.jsindex 4ac130696..cb04dea0e 100644--- a/api/_lib/llm.js+++ b/api/_lib/llm.js@@ -13,6 +13,13 @@// prod are routinely invalid or out of quota, so a chain that depends on// them fails.//+// • THE FREE TIER KEEPS GROWING. SambaNova, Mistral (Experiment tier),+// Z.AI GLM Flash, Cloudflare Workers AI, and SiliconFlow are optional+// keyed rungs (each skipped when its env var is unset), and LLM7.io is a+// second keyless anonymous rung alongside OVH and Pollinations. Every new+// free provider is an independent quota pool, so adding one raises the+// ceiling of traffic the platform serves at zero marginal cost.+//// • VERTEX GEMINI IS THE RELIABILITY ANCHOR. When GOOGLE_CLOUD_PROJECT is// set (every Cloud Run deploy), Gemini Flash-Lite on Vertex — service// account auth, GCP-credit billing, no third-party quota — sits between@@ -85,6 +92,37 @@ const NVIDIA_NEMOTRON_MODEL = 'nvidia/nvidia-nemotron-nano-9b-v2';// model per IP quota, so it rides at the back of the 70B-class group rather// than leading. https://help.ovhcloud.com/csm/en-public-cloud-ai-endpoints-capabilitiesconst OVH_MODEL = 'Meta-Llama-3_3-70B-Instruct';+// SambaNova Cloud free tier (cloud.sambanova.ai): the same Llama 3.3 70B on+// yet another independent free quota pool (about 20 req/min and 200K+// tokens/day per model, no card required). Model id verified live against+// GET https://api.sambanova.ai/v1/models on 2026-08-05.+const SAMBANOVA_MODEL = 'Meta-Llama-3.3-70B-Instruct';+// Mistral's Experiment tier (console.mistral.ai): a genuinely large free+// quota (about 1B tokens/month at 1 req/sec) in exchange for opting the+// account into data training, which is fine for this chain: it carries+// platform utility traffic, not user secrets. The -latest alias tracks+// Mistral's current small release without a code change.+const MISTRAL_MODEL = 'mistral-small-latest';+// Z.AI (Zhipu) Flash lane (docs.z.ai): glm-4.7-flash is one of the+// permanently free, rate-limited Flash models on the OpenAI-compatible+// endpoint at api.z.ai. Strong coding/chat quality for a free lane.+const ZAI_MODEL = 'glm-4.7-flash';+// Cloudflare Workers AI: 10,000 free neurons/day on the account-scoped+// OpenAI-compatible endpoint. Needs BOTH CLOUDFLARE_ACCOUNT_ID and+// CLOUDFLARE_AI_API_TOKEN (the URL embeds the account id). The fp8-fast+// build keeps this rung in the 70B class.+const CLOUDFLARE_MODEL = '@cf/meta/llama-3.3-70b-instruct-fp8-fast';+// SiliconFlow international (siliconflow.com): free-tier Qwen3 8B. A+// capability step-down, so it rides with the small-model group at the end+// of the free section; enable_thinking:false (extraBody below) keeps Qwen3's+// reasoning mode off so message.content carries the actual answer.+const SILICONFLOW_MODEL = 'Qwen/Qwen3-8B';+// LLM7.io keyless anonymous tier (api.llm7.io): community-run gateway, no+// key and no signup, about 30 req/min per IP. Free catalog probed live+// 2026-08-05; gemini-3.1-flash-lite returned real content there, while the+// gpt-oss route spends its token budget on reasoning and can hand back an+// empty content field, so it is deliberately not used.+const LLM7_MODEL = 'gemini-3.1-flash-lite';// Pollinations' keyless anonymous tier: also no key, routes to a hosted// gpt-oss-20b. Smaller than the 70B rungs above it, so it sits in the// capability-step-down group alongside Groq's instant lane — an always-on@@ -152,7 +190,7 @@ export async function checkUserLlmSpendCap(userId, { anthropicKey, grokKey } = {-- on the platform key is real spend and counts against the cap.AND NOT (provider LIKE 'openrouter%' AND (model IS NULL OR model LIKE '%:free'))AND provider NOT LIKE 'vertex%'- AND provider NOT IN ('nvidia', 'cerebras', 'gemini', 'ovh', 'pollinations')+ AND provider NOT IN ('nvidia', 'cerebras', 'gemini', 'ovh', 'pollinations', 'sambanova', 'mistral', 'zai', 'cloudflare', 'siliconflow', 'llm7')AND created_at > NOW() - INTERVAL '24 hours'`;const spent = Number(row?.spent ?? 0);@@ -485,6 +523,48 @@ export function providerChain({ anthropicKey, anthropicModel, grokKey = null, grtimeoutMs: nvidiaLaneTimeoutMs(),}));}+ // SambaNova's free tier: the same Llama 3.3 70B on a fourth independent+ // quota pool, so a day that exhausts Groq, Cerebras, and NVIDIA at once+ // still has a 70B-class free rung with budget left.+ if (env.SAMBANOVA_API_KEY) {+ chain.push(openaiCompatProvider({+ name: 'sambanova',+ key: env.SAMBANOVA_API_KEY,+ url: 'https://api.sambanova.ai/v1/chat/completions',+ model: SAMBANOVA_MODEL,+ }));+ }+ // Mistral's Experiment tier: the largest free quota in the chain (about 1B+ // tokens/month). Mistral Small is not a 70B model, but its quality sits+ // with this group rather than the step-down group below.+ if (env.MISTRAL_API_KEY) {+ chain.push(openaiCompatProvider({+ name: 'mistral',+ key: env.MISTRAL_API_KEY,+ url: 'https://api.mistral.ai/v1/chat/completions',+ model: MISTRAL_MODEL,+ }));+ }+ // Z.AI's permanently free GLM Flash lane: another independent quota pool+ // with quality comparable to the rungs above it.+ if (env.ZAI_API_KEY) {+ chain.push(openaiCompatProvider({+ name: 'zai',+ key: env.ZAI_API_KEY,+ url: 'https://api.z.ai/api/paas/v4/chat/completions',+ model: ZAI_MODEL,+ }));+ }+ // Cloudflare Workers AI free tier: 70B-class Llama at the edge, gated on+ // both halves of the credential because the URL embeds the account id.+ if (env.CLOUDFLARE_ACCOUNT_ID && env.CLOUDFLARE_AI_API_TOKEN) {+ chain.push(openaiCompatProvider({+ name: 'cloudflare',+ key: env.CLOUDFLARE_AI_API_TOKEN,+ url: `https://api.cloudflare.com/client/v4/accounts/${env.CLOUDFLARE_ACCOUNT_ID}/ai/v1/chat/completions`,+ model: CLOUDFLARE_MODEL,+ }));+ }// OVH AI Endpoints anonymous tier — no key required, always available.// Last of the 70B-class free rungs because its per-model anonymous quota// (2 req/min/IP) is the tightest in the chain; everything with a real key@@ -518,6 +598,26 @@ export function providerChain({ anthropicKey, anthropicModel, grokKey = null, grurl: 'https://text.pollinations.ai/openai',model: POLLINATIONS_MODEL,}));+ // LLM7.io keyless anonymous tier: the third no-key rung. Sits with the+ // step-down group (flash-lite class) right after Pollinations, so even a+ // zero-env deployment has three independent keyless lanes to fall through.+ chain.push(openaiCompatProvider({+ name: 'llm7',+ url: 'https://api.llm7.io/v1/chat/completions',+ model: LLM7_MODEL,+ }));+ // SiliconFlow free tier: keyed 8B step-down on its own quota pool.+ // enable_thinking:false forces Qwen3 out of reasoning mode so the answer+ // lands in message.content instead of a reasoning field.+ if (env.SILICONFLOW_API_KEY) {+ chain.push(openaiCompatProvider({+ name: 'siliconflow',+ key: env.SILICONFLOW_API_KEY,+ url: 'https://api.siliconflow.com/v1/chat/completions',+ model: SILICONFLOW_MODEL,+ extraBody: { enable_thinking: false },+ }));+ }// Last free rung: Groq's instant lane. Smaller model (a capability// step-down), but its per-model quota is separate from the 70B lane and it// still beats erroring out or landing on a dead paid key.diff --git a/api/agents/copilot.js b/api/agents/copilot.jsindex 7d7710135..f14bf711c 100644--- a/api/agents/copilot.js+++ b/api/agents/copilot.js@@ -85,6 +85,18 @@ export function providerChain() {if (env.NVIDIA_API_KEY) {chain.push({ name: 'nvidia', url: 'https://integrate.api.nvidia.com/v1/chat/completions', key: env.NVIDIA_API_KEY, model: 'meta/llama-3.3-70b-instruct' });}+ // Three more free lanes, same OpenAI wire format including tools + streamed+ // tool_calls: SambaNova (Llama 3.3 70B, own quota pool), Mistral (Experiment+ // tier, about 1B free tokens/month), and Z.AI's free GLM Flash lane.+ if (env.SAMBANOVA_API_KEY) {+ chain.push({ name: 'sambanova', url: 'https://api.sambanova.ai/v1/chat/completions', key: env.SAMBANOVA_API_KEY, model: 'Meta-Llama-3.3-70B-Instruct' });+ }+ if (env.MISTRAL_API_KEY) {+ chain.push({ name: 'mistral', url: 'https://api.mistral.ai/v1/chat/completions', key: env.MISTRAL_API_KEY, model: 'mistral-small-latest' });+ }+ if (env.ZAI_API_KEY) {+ chain.push({ name: 'zai', url: 'https://api.z.ai/api/paas/v4/chat/completions', key: env.ZAI_API_KEY, model: 'glm-4.7-flash' });+ }if (env.OPENAI_API_KEY) {chain.push({ name: 'openai', url: 'https://api.openai.com/v1/chat/completions', key: env.OPENAI_API_KEY, model: 'gpt-5.4-nano' });}diff --git a/api/brain/chat.js b/api/brain/chat.jsindex 8a92beb5a..0ba09bd6c 100644--- a/api/brain/chat.js+++ b/api/brain/chat.js@@ -526,6 +526,30 @@ export function freeFallbackChain(providerKey, spec, primary) {meter: { provider: 'nvidia', model: 'meta/llama-3.3-70b-instruct' },});}+ // Three more free lanes on independent quota pools (see api/_lib/llm.js for+ // each tier's limits): SambaNova (Llama 3.3 70B), Mistral (Experiment tier),+ // and Z.AI's free GLM Flash. All OpenAI-compatible Chat Completions.+ if (env.SAMBANOVA_API_KEY) {+ chain.push({+ label: 'sambanova/Meta-Llama-3.3-70B-Instruct',+ model: createOpenAI({ apiKey: env.SAMBANOVA_API_KEY, baseURL: 'https://api.sambanova.ai/v1' }).chat('Meta-Llama-3.3-70B-Instruct'),+ meter: { provider: 'sambanova', model: 'Meta-Llama-3.3-70B-Instruct' },+ });+ }+ if (env.MISTRAL_API_KEY) {+ chain.push({+ label: 'mistral/mistral-small-latest',+ model: createOpenAI({ apiKey: env.MISTRAL_API_KEY, baseURL: 'https://api.mistral.ai/v1' }).chat('mistral-small-latest'),+ meter: { provider: 'mistral', model: 'mistral-small-latest' },+ });+ }+ if (env.ZAI_API_KEY) {+ chain.push({+ label: 'zai/glm-4.7-flash',+ model: createOpenAI({ apiKey: env.ZAI_API_KEY, baseURL: 'https://api.z.ai/api/paas/v4' }).chat('glm-4.7-flash'),+ meter: { provider: 'zai', model: 'glm-4.7-flash' },+ });+ }// Credits-funded Vertex Gemini anchor, ALWAYS at the tail when the GCP// project is set (api/chat.js semantics, see api/_lib/vertex-gemini.js). No// key gates it and nothing may evict it: it is the rung that keeps /braindiff --git a/api/chat.js b/api/chat.jsindex 844b85fee..399865be1 100644--- a/api/chat.js+++ b/api/chat.js@@ -9,9 +9,12 @@// 2. GROQ_API_KEY → Groq (free platform key — default).// 3. OPENROUTER_API_KEY → OpenRouter free tier.// 4. NVIDIA_API_KEY → NVIDIA NIM free tier (third independent free lane).-// 5. ANTHROPIC_API_KEY → Anthropic (paid backstop — BYOK or host key).-// 6. OPENAI_API_KEY → OpenAI (paid backstop).-// 7. WATSONX_API_KEY (+ project) → IBM Granite on watsonx.ai (server key only;+// 5. SAMBANOVA_API_KEY -> SambaNova Cloud free tier (fourth free lane).+// 6. MISTRAL_API_KEY -> Mistral Experiment tier (largest free quota).+// 7. ZAI_API_KEY -> Z.AI free GLM Flash lane (sixth free lane).+// 8. ANTHROPIC_API_KEY -> Anthropic (paid backstop, BYOK or host key).+// 9. OPENAI_API_KEY -> OpenAI (paid backstop).+// 10. WATSONX_API_KEY (+ project) -> IBM Granite on watsonx.ai (server key only;// explicit `provider: "watsonx"` from the client, never the silent default).// Anthropic, the OpenAI-compatible providers (OpenRouter / Groq / OpenAI), and// watsonx.ai use different request shapes, auth, tool-call wire formats, and SSE@@ -145,6 +148,30 @@ const PROVIDERS = {url: 'https://integrate.api.nvidia.com/v1/chat/completions',style: 'openai',},+ // SambaNova Cloud (cloud.sambanova.ai): free-tier OpenAI-compatible Llama+ // 3.3 70B on its own quota pool. The fourth independent free lane.+ sambanova: {+ envKey: 'SAMBANOVA_API_KEY',+ defaultModel: PROVIDER_MODEL_DEFAULTS.sambanova,+ url: 'https://api.sambanova.ai/v1/chat/completions',+ style: 'openai',+ },+ // Mistral Experiment tier (console.mistral.ai): OpenAI-compatible, about+ // 1B free tokens/month. The largest free quota in the ladder.+ mistral: {+ envKey: 'MISTRAL_API_KEY',+ defaultModel: PROVIDER_MODEL_DEFAULTS.mistral,+ url: 'https://api.mistral.ai/v1/chat/completions',+ style: 'openai',+ },+ // Z.AI (docs.z.ai): permanently free, rate-limited GLM Flash models on an+ // OpenAI-compatible endpoint. A sixth independent free lane.+ zai: {+ envKey: 'ZAI_API_KEY',+ defaultModel: PROVIDER_MODEL_DEFAULTS.zai,+ url: 'https://api.z.ai/api/paas/v4/chat/completions',+ style: 'openai',+ },openai: {envKey: 'OPENAI_API_KEY',defaultModel: DEFAULT_OPENAI_MODEL,@@ -209,7 +236,7 @@ const chatBody = z.object({persona_override: z.string().trim().min(1).max(16000).optional(),agentId: z.string().uuid().optional(),provider: z- .enum(['anthropic', 'openrouter', 'groq', 'nvidia', 'openai', 'grok', 'watsonx', 'orchestrate'])+ .enum(['anthropic', 'openrouter', 'groq', 'nvidia', 'sambanova', 'mistral', 'zai', 'openai', 'grok', 'watsonx', 'orchestrate']).optional(),model: z.string().min(1).max(120).optional(),history: z@@ -1211,6 +1238,11 @@ const FALLBACK_SIBLINGS = {// model would re-hit the same throttle — keep a single slot and give the// next fallback slot to a different provider.nvidia: ['meta/llama-3.3-70b-instruct'],+ // Same one-account rationale as Groq/NVIDIA: one slot each, then move on+ // to a different provider.+ sambanova: ['Meta-Llama-3.3-70B-Instruct'],+ mistral: ['mistral-small-latest'],+ zai: ['glm-4.7-flash'],anthropic: ['claude-sonnet-5', 'claude-sonnet-4-6', 'claude-haiku-4-5-20251001'],openai: ['gpt-5.4-nano'],grok: ['grok-4.5', 'grok-4.1-fast'],diff --git a/api/llm/anthropic.js b/api/llm/anthropic.jsindex 53c023f1d..897bc5403 100644--- a/api/llm/anthropic.js+++ b/api/llm/anthropic.js@@ -104,6 +104,15 @@ const MODELS = {envKey: 'NVIDIA_API_KEY',},+ // SambaNova Cloud free tier: Llama 3.3 70B on an independent quota pool.+ // Selectable and a free fallback rung (see modelFallbackChain below).+ 'Meta-Llama-3.3-70B-Instruct': { kind: 'openai', provider: 'sambanova', envKey: 'SAMBANOVA_API_KEY' },++ // Mistral Experiment tier (about 1B free tokens/month) and Z.AI's free GLM+ // Flash lane. Both OpenAI-compatible and tool-call capable.+ 'mistral-small-latest': { kind: 'openai', provider: 'mistral', envKey: 'MISTRAL_API_KEY' },+ 'glm-4.7-flash': { kind: 'openai', provider: 'zai', envKey: 'ZAI_API_KEY' },+// xAI Grok (paid, host's key). OpenAI-compatible and tool-call capable, so// it shares the 'openai' branch. Selectable only; never a free fallback.'grok-4.5': { kind: 'openai', provider: 'grok', envKey: 'GROK_API_KEY' },@@ -155,6 +164,9 @@ const UPSTREAM_URL = {openrouter: 'https://openrouter.ai/api/v1/chat/completions',groq: 'https://api.groq.com/openai/v1/chat/completions',nvidia: 'https://integrate.api.nvidia.com/v1/chat/completions',+ sambanova: 'https://api.sambanova.ai/v1/chat/completions',+ mistral: 'https://api.mistral.ai/v1/chat/completions',+ zai: 'https://api.z.ai/api/paas/v4/chat/completions',grok: 'https://api.x.ai/v1/chat/completions',};@@ -187,6 +199,10 @@ export function modelFallbackChain(requestedModel) {...['meta-llama/llama-3.1-8b-instruct:free','meta/llama-4-maverick-17b-128e-instruct',+ // SambaNova free 70B: an independent quota pool between the NVIDIA+ // free rung and the paid Anthropic backstop. Skipped at call time+ // when SAMBANOVA_API_KEY is unset, like every keyed rung here.+ 'Meta-Llama-3.3-70B-Instruct','claude-haiku-4-5-20251001',].filter((m) => m !== requestedModel),];diff --git a/api/marketplace/[action].js b/api/marketplace/[action].jsindex 2e913356f..ccd9c955d 100644--- a/api/marketplace/[action].js+++ b/api/marketplace/[action].js@@ -901,6 +901,26 @@ const PREVIEW_PROVIDERS = {defaultModel: 'meta/llama-3.3-70b-instruct',style: 'openai',},+ // SambaNova / Mistral / Z.AI free tiers: independent quota pools, same+ // OpenAI wire format (see api/_lib/llm.js for each tier's limits).+ sambanova: {+ envKey: 'SAMBANOVA_API_KEY',+ url: 'https://api.sambanova.ai/v1/chat/completions',+ defaultModel: 'Meta-Llama-3.3-70B-Instruct',+ style: 'openai',+ },+ mistral: {+ envKey: 'MISTRAL_API_KEY',+ url: 'https://api.mistral.ai/v1/chat/completions',+ defaultModel: 'mistral-small-latest',+ style: 'openai',+ },+ zai: {+ envKey: 'ZAI_API_KEY',+ url: 'https://api.z.ai/api/paas/v4/chat/completions',+ defaultModel: 'glm-4.7-flash',+ style: 'openai',+ },openai: {envKey: 'OPENAI_API_KEY',url: 'https://api.openai.com/v1/chat/completions',@@ -1077,11 +1097,14 @@ async function handlePreview(req, res, id) {// 1. groq — free, fast, first-attempt reliable (per-minute caps only)// 2. openrouter — free Llama fallback// 3. nvidia — NVIDIA NIM free tier, independent third lane-// 4. anthropic — paid backstop-// 5. openai — paid backstop (account may be over quota)-// 6. grok — paid backstop (xAI, budget tier)+// 4. sambanova - SambaNova Cloud free tier, fourth free lane+// 5. mistral - Mistral Experiment tier, largest free quota+// 6. zai - Z.AI free GLM Flash lane+// 7. anthropic - paid backstop+// 8. openai - paid backstop (account may be over quota)+// 9. grok - paid backstop (xAI, budget tier)export function buildPreviewRoutes() {- const order = ['groq', 'openrouter', 'nvidia', 'anthropic', 'openai', 'grok'];+ const order = ['groq', 'openrouter', 'nvidia', 'sambanova', 'mistral', 'zai', 'anthropic', 'openai', 'grok'];const routes = [];for (const name of order) {const cfg = PREVIEW_PROVIDERS[name];diff --git a/api/widgets/[id]/[action].js b/api/widgets/[id]/[action].jsindex 6458920f9..f75f99f62 100644--- a/api/widgets/[id]/[action].js+++ b/api/widgets/[id]/[action].js@@ -94,6 +94,27 @@ const PROVIDERS = {url: 'https://integrate.api.nvidia.com/v1/chat/completions',style: 'openai',},+ // SambaNova / Mistral / Z.AI free tiers (see api/_lib/llm.js for limits):+ // independent quota pools, OpenAI wire format with tool calls, and all in+ // DEFAULT_PROVIDER_ORDER, so pickProviderChain needs entries here.+ sambanova: {+ envKey: 'SAMBANOVA_API_KEY',+ defaultModel: PROVIDER_MODEL_DEFAULTS.sambanova,+ url: 'https://api.sambanova.ai/v1/chat/completions',+ style: 'openai',+ },+ mistral: {+ envKey: 'MISTRAL_API_KEY',+ defaultModel: PROVIDER_MODEL_DEFAULTS.mistral,+ url: 'https://api.mistral.ai/v1/chat/completions',+ style: 'openai',+ },+ zai: {+ envKey: 'ZAI_API_KEY',+ defaultModel: PROVIDER_MODEL_DEFAULTS.zai,+ url: 'https://api.z.ai/api/paas/v4/chat/completions',+ style: 'openai',+ },openai: {envKey: 'OPENAI_API_KEY',defaultModel: 'gpt-5.4-nano',@@ -121,11 +142,11 @@ const PROVIDERS = {// Brain settings that surface in widget config. `auto` picks the first// configured provider; `custom`/`none` keep their legacy meanings.-const BRAIN_PROVIDERS = new Set(['auto', 'anthropic', 'openrouter', 'groq', 'nvidia', 'openai', 'grok', 'watsonx']);+const BRAIN_PROVIDERS = new Set(['auto', 'anthropic', 'openrouter', 'groq', 'nvidia', 'sambanova', 'mistral', 'zai', 'openai', 'grok', 'watsonx']);const chatBody = z.object({message: z.string().trim().min(1).max(4000),- provider: z.enum(['auto', 'anthropic', 'openrouter', 'groq', 'nvidia', 'openai', 'grok', 'watsonx']).optional(),+ provider: z.enum(['auto', 'anthropic', 'openrouter', 'groq', 'nvidia', 'sambanova', 'mistral', 'zai', 'openai', 'grok', 'watsonx']).optional(),model: z.string().min(1).max(160).optional(),history: z.array(diff --git a/docs/free-llm-providers.md b/docs/free-llm-providers.mdnew file mode 100644index 000000000..32df076bd--- /dev/null+++ b/docs/free-llm-providers.md@@ -0,0 +1,59 @@+# Free LLM providers: the failover chain++three.ws never depends on a single AI vendor. Every text completion on the platform (chat, agent brains, copilots, translations, moderation helpers) runs through one shared failover chain that tries free providers first, in order, and only touches a paid key as a last resort. This page is the map of that chain: which providers are in it, what each one costs (nothing), where the keys come from, and how to add the next one.++The chain lives in [`api/_lib/llm.js`](../api/_lib/llm.js) (`providerChain()` + `llmComplete()`). The interactive chat ladder in [`api/chat.js`](../api/chat.js) uses the same policy with a shorter list (see `DEFAULT_PROVIDER_ORDER` in [`api/_lib/chat-models.js`](../api/_lib/chat-models.js)).++## The chain, in order++Free rungs run first, 70B-class models before smaller ones. A keyed rung is skipped when its env var is unset; the three keyless rungs are always present, so the chain can never be empty.++| # | Rung | Model | Key | Free tier |+|---|------|-------|-----|-----------|+| 1 | Groq | `llama-3.3-70b-versatile` | `GROQ_API_KEY` | Per-minute and per-day caps, no card. [console.groq.com](https://console.groq.com) |+| 2 | Cerebras | `llama-3.3-70b` | `CEREBRAS_API_KEY` | About 1M tokens/day. [cloud.cerebras.ai](https://cloud.cerebras.ai) |+| 3 | OpenRouter | `openai/gpt-oss-20b:free` | `OPENROUTER_API_KEY` (+ fallback keys) | `:free` models only; the platform key is never billed. [openrouter.ai](https://openrouter.ai) |+| 4 | NVIDIA NIM | `meta/llama-3.3-70b-instruct` | `NVIDIA_API_KEY` | Free developer tier, about 40 req/min. [build.nvidia.com](https://build.nvidia.com) |+| 5 | SambaNova | `Meta-Llama-3.3-70B-Instruct` | `SAMBANOVA_API_KEY` | About 20 req/min, 200K tokens/day per model, no card. [cloud.sambanova.ai](https://cloud.sambanova.ai) |+| 6 | Mistral | `mistral-small-latest` | `MISTRAL_API_KEY` | Experiment tier: about 1B tokens/month at 1 req/sec (account opts into data training). [console.mistral.ai](https://console.mistral.ai) |+| 7 | Z.AI | `glm-4.7-flash` | `ZAI_API_KEY` | Permanently free, rate-limited Flash models. [z.ai](https://z.ai), docs at [docs.z.ai](https://docs.z.ai) |+| 8 | Cloudflare Workers AI | `@cf/meta/llama-3.3-70b-instruct-fp8-fast` | `CLOUDFLARE_ACCOUNT_ID` + `CLOUDFLARE_AI_API_TOKEN` | 10,000 neurons/day. [developers.cloudflare.com/workers-ai](https://developers.cloudflare.com/workers-ai/) |+| 9 | OVHcloud AI Endpoints | `Meta-Llama-3_3-70B-Instruct` | none (keyless) | Anonymous trial lane, 2 req/min per IP. |+| 10 | Gemini (AI Studio) | `gemini-2.5-flash-lite` | `GEMINI_API_KEY` | AI Studio free tier, no card. [aistudio.google.com](https://aistudio.google.com) |+| 11 | Vertex Gemini | `google/gemini-2.5-flash` | GCP service account | The reliability anchor: billed to platform GCP credits, no third-party quota. |+| 12 | Pollinations | `openai-fast` | none (keyless) | Anonymous, always on. |+| 13 | LLM7.io | `gemini-3.1-flash-lite` | none (keyless) | Anonymous, about 30 req/min per IP. |+| 14 | SiliconFlow | `Qwen/Qwen3-8B` | `SILICONFLOW_API_KEY` | Free-tier small model, own quota pool. [siliconflow.com](https://siliconflow.com) |+| 15 | Groq instant | `llama-3.1-8b-instant` | `GROQ_API_KEY` | Separate per-model quota from rung 1. |++After rung 15 come the paid backstops (Vertex Claude, Anthropic, OpenAI, Grok), which never lead and which no flow depends on.++The interactive chat ladder (`/api/chat`) uses: groq → openrouter → nvidia → sambanova → mistral → zai → paid backstops, with the Vertex Gemini anchor always appended at the tail. SambaNova, Mistral, and Z.AI are also selectable as explicit `provider` values in the chat API, and anonymous callers may use them.++## Why so many++Every rung is an independent quota pool on independent infrastructure. Free tiers throttle, retire models without notice (OpenRouter dropped its whole `:free` Llama roster in one day, GitHub Models was retired outright in 2026), and queue under load (NVIDIA NIM). One provider failing costs nothing; the chain moves on in under a second. The platform's baseline reliability is the product of how many independent free lanes stand between a request and an error.++Two providers were evaluated and deliberately excluded:++- **GitHub Models**: in a scheduled retirement brownout (HTTP 410) as of August 2026; the product is being sunset.+- **Cohere**: the free trial key is licensed for non-commercial use only, which three.ws does not satisfy.++## Cost accounting++All of these rungs are zero-marginal-cost, and the accounting knows it:++- `FREE_PROVIDERS` in [`api/_lib/llm-pricing.js`](../api/_lib/llm-pricing.js) prices their traffic at $0 (vs "unpriced", which is an audit failure).+- The per-user daily spend cap in `checkUserLlmSpendCap()` ([`api/_lib/llm.js`](../api/_lib/llm.js)) excludes them, so free traffic can never lock a user out.++## Adding the next provider++1. Get the model id and OpenAI-compatible endpoint (nearly every free tier has one; probe it with `curl` before writing code).+2. `api/_lib/env.js`: add the key getter with a comment stating the tier's limits.+3. `api/_lib/llm.js`: add a model `const` with rationale, then a guarded `chain.push(openaiCompatProvider({...}))` at the right rung: 70B-class before step-downs, always before the Vertex anchor if free.+4. `api/_lib/llm-pricing.js`: add the provider name to `FREE_PROVIDERS`; add it to the spend-cap exclusion list in `llm.js`.+5. `tests/api/llm-free-chain-reachability.test.js`: add the rung to `HOSTS`/`FREE_CHAIN`/`ENV_KEYS`; the exact-order assertion fails until you do.+6. If the provider should be user-selectable in chat: register it in `api/chat.js` (`PROVIDERS`, the provider enum, `FALLBACK_SIBLINGS`) and `api/_lib/chat-models.js` (`MODEL_CATALOG`, `PROVIDER_MODEL_DEFAULTS`, `DEFAULT_PROVIDER_ORDER`, `ANON_PROVIDER_LIST`).+7. `.env.example` and the env tables in [`ARCHITECTURE.md`](../ARCHITECTURE.md).++Related: [nvidia-models.md](nvidia-models.md) for the full NVIDIA NIM surface map.diff --git a/docs/start-here.md b/docs/start-here.mdindex 77adea811..96cd697d3 100644--- a/docs/start-here.md+++ b/docs/start-here.md@@ -149,6 +149,7 @@ Deeper references that don't fit a track above but answer real questions:- [Agent Monitor](./monitor.md): the ops room at [/monitor](https://three.ws/monitor), twelve live panels covering fleet activity, money, revenue, creations and uptime, plus how to add a panel- [Design tokens](./DESIGN-TOKENS.md): the canonical design vocabulary (colors, spacing, type, motion) every surface builds from- [NVIDIA models on three.ws](./nvidia-models.md): the free hosted inference layer model by model, one key behind text-to-3D, chat, vision, embeddings, safety, and speech+- [Free LLM providers](./free-llm-providers.md): the failover chain of a dozen free AI providers behind every text completion, what each free tier gives, and how to add the next rung- [NVIDIA Inception membership](./nvidia-inception.md): what the platform already runs on NVIDIA silicon and what the program adds on top- [The generator was never the hard part](./nvidia-nemotron-spotlight.md): our Nemotron Nano write-up, published on the NVIDIA Developer Forums- [three.ws on the AWS Builder Center](./aws-builder-center.md): the index of our published AWS engineering writing, what code each article documents, and the checklist for publishing the next onediff --git a/scripts/i18n-translate.mjs b/scripts/i18n-translate.mjsindex 194e40278..5d8b10803 100644--- a/scripts/i18n-translate.mjs+++ b/scripts/i18n-translate.mjs@@ -155,6 +155,7 @@ const PROVIDER_DEFAULT_MODEL = {groq: 'llama-3.3-70b-versatile',openrouter: 'openai/gpt-oss-20b:free',nvidia: 'meta/llama-3.3-70b-instruct',+ mistral: 'mistral-small-latest',openai: 'gpt-4o-mini',anthropic: 'claude-haiku-4-5-20251001',};@@ -177,6 +178,13 @@ const OPENAI_COMPAT = {envKey: 'NVIDIA_API_KEY',url: () => 'https://integrate.api.nvidia.com/v1/chat/completions',},+ // Mistral Experiment tier (free, about 1B tokens/month): the strongest free+ // lane for European-language output, and it honors response_format json.+ mistral: {+ envKey: 'MISTRAL_API_KEY',+ url: () => 'https://api.mistral.ai/v1/chat/completions',+ jsonMode: true,+ },openai: {envKey: 'OPENAI_API_KEY',url: () => `${process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1'}/chat/completions`,@@ -440,7 +448,7 @@ function backend() {if (cfg.provider === 'vertex') return callVertex;if (OPENAI_COMPAT[cfg.provider]) return callOpenAICompat;throw new Error(- `unknown provider: ${cfg.provider} (use gemini, groq, openrouter, nvidia, vertex, openai, or anthropic)`,+ `unknown provider: ${cfg.provider} (use gemini, groq, openrouter, nvidia, mistral, vertex, openai, or anthropic)`,);}diff --git a/tests/api/llm-free-chain-reachability.test.js b/tests/api/llm-free-chain-reachability.test.jsindex d181e20b8..4e2cf5a67 100644--- a/tests/api/llm-free-chain-reachability.test.js+++ b/tests/api/llm-free-chain-reachability.test.js@@ -24,10 +24,16 @@ const HOSTS = {cerebras: 'api.cerebras.ai',openrouter: 'openrouter.ai',nvidia: 'integrate.api.nvidia.com',+ sambanova: 'api.sambanova.ai',+ mistral: 'api.mistral.ai',+ zai: 'api.z.ai',+ cloudflare: 'api.cloudflare.com',ovh: 'oai.endpoints.kepler.ai.cloud.ovh.net',gemini: 'generativelanguage.googleapis.com',vertex: 'aiplatform.googleapis.com',pollinations: 'text.pollinations.ai',+ llm7: 'api.llm7.io',+ siliconflow: 'api.siliconflow.com',};// The free chain in providerChain() order, with the env each rung needs. Groq@@ -39,10 +45,16 @@ const FREE_CHAIN = [{ provider: 'cerebras', host: HOSTS.cerebras, model: 'llama-3.3-70b' },{ provider: 'openrouter', host: HOSTS.openrouter, model: 'openai/gpt-oss-20b:free' },{ provider: 'nvidia', host: HOSTS.nvidia, model: 'meta/llama-3.3-70b-instruct' },+ { provider: 'sambanova', host: HOSTS.sambanova, model: 'Meta-Llama-3.3-70B-Instruct' },+ { provider: 'mistral', host: HOSTS.mistral, model: 'mistral-small-latest' },+ { provider: 'zai', host: HOSTS.zai, model: 'glm-4.7-flash' },+ { provider: 'cloudflare', host: HOSTS.cloudflare, model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast' },{ provider: 'ovh', host: HOSTS.ovh, model: 'Meta-Llama-3_3-70B-Instruct' },{ provider: 'gemini', host: HOSTS.gemini, model: 'gemini-2.5-flash-lite' },{ provider: 'vertex-gemini', host: HOSTS.vertex, model: 'google/gemini-2.5-flash' },{ provider: 'pollinations', host: HOSTS.pollinations, model: 'openai-fast' },+ { provider: 'llm7', host: HOSTS.llm7, model: 'gemini-3.1-flash-lite' },+ { provider: 'siliconflow', host: HOSTS.siliconflow, model: 'Qwen/Qwen3-8B' },{ provider: 'groq#instant', host: HOSTS.groq, model: 'llama-3.1-8b-instant' },];@@ -52,6 +64,12 @@ const ENV_KEYS = ['OPENROUTER_API_KEY','OPENROUTER_FALLBACK_KEYS','NVIDIA_API_KEY',+ 'SAMBANOVA_API_KEY',+ 'MISTRAL_API_KEY',+ 'ZAI_API_KEY',+ 'CLOUDFLARE_ACCOUNT_ID',+ 'CLOUDFLARE_AI_API_TOKEN',+ 'SILICONFLOW_API_KEY','GEMINI_API_KEY','GOOGLE_CLOUD_PROJECT','GOOGLE_CLOUD_LOCATION_GEMINI',@@ -73,6 +91,12 @@ function configureFreeLanes() {process.env.CEREBRAS_API_KEY = 'c';process.env.OPENROUTER_API_KEY = 'or';process.env.NVIDIA_API_KEY = 'nvapi-x';+ process.env.SAMBANOVA_API_KEY = 'sn';+ process.env.MISTRAL_API_KEY = 'mi';+ process.env.ZAI_API_KEY = 'z';+ process.env.CLOUDFLARE_ACCOUNT_ID = 'cf-acct';+ process.env.CLOUDFLARE_AI_API_TOKEN = 'cf-token';+ process.env.SILICONFLOW_API_KEY = 'sf';process.env.GEMINI_API_KEY = 'gem';process.env.GOOGLE_CLOUD_PROJECT = 'test-project';// The NIM lane's own cap is floored at 2s; keep it there so a transport@@ -182,4 +206,19 @@ describe('free chain: every rung is reachable through a transport-level failure'expect(out.provider).toBe('pollinations');expect(out.text).toBe('keyless floor');}, 20_000);++ // Third keyless rung: with nothing configured and BOTH OVH and Pollinations+ // dead at the transport level, LLM7 must still answer.+ it('serves from LLM7 when OVH and Pollinations both die and nothing is configured', async () => {+ globalThis.fetch = vi.fn(async (url) => {+ const u = String(url);+ if (u.includes(HOSTS.ovh)) throw transportFailure('reset');+ if (u.includes(HOSTS.pollinations)) throw transportFailure('abort');+ if (u.includes(HOSTS.llm7)) return okOpenAiShape('third keyless floor', 'gemini-3.1-flash-lite');+ throw new Error(`unexpected fetch: ${u}`);+ });+ const out = await llm.llmComplete({ user: 'u', timeoutMs: 20_000 });+ expect(out.provider).toBe('llm7');+ expect(out.text).toBe('third keyless floor');+ }, 20_000);});diff --git a/tests/api/llm.test.js b/tests/api/llm.test.jsindex 9d430590b..b01f8e501 100644--- a/tests/api/llm.test.js+++ b/tests/api/llm.test.js@@ -45,6 +45,7 @@ const ANTHROPIC_HOST = 'api.anthropic.com';const OPENAI_HOST = 'api.openai.com';const OVH_HOST = 'oai.endpoints.kepler.ai.cloud.ovh.net';const POLLINATIONS_HOST = 'text.pollinations.ai';+const LLM7_HOST = 'api.llm7.io';const openaiShape = (content) => okJson({choices: [{ message: { content } }],@@ -211,10 +212,10 @@ describe('llmComplete — multiple OpenRouter keys', () => {});await expect(llm.llmComplete({ system: 's', user: 'u' })).rejects.toMatchObject({ status: 502 });// or-same is deduped to a single key (one :free rung), then or-extra's :free- // rung — two OpenRouter fetches (without dedup or-same would be tried again as- // a fallback too). The chain then falls through the two unconditional keyless- // lanes (OVH, Pollinations) before giving up — four fetches total.- expect(n).toBe(4);+ // rung, two OpenRouter fetches (without dedup or-same would be tried again as+ // a fallback too). The chain then falls through the three unconditional+ // keyless lanes (OVH, Pollinations, LLM7) before giving up: five fetches total.+ expect(n).toBe(5);});it('llmConfigured is true with only fallback keys set', () => {@@ -545,7 +546,11 @@ describe('llmComplete — failure modes', () => {// empty. What used to be "no provider configured" now degrades to the last// upstream error from those keyless lanes instead.it('throws the last upstream error (502), not LlmUnavailableError, when no keys are configured and the keyless lanes also fail', async () => {- installFetch({ [OVH_HOST]: errResp(429, 'rate limited'), [POLLINATIONS_HOST]: errResp(502, 'bad gateway') });+ installFetch({+ [OVH_HOST]: errResp(429, 'rate limited'),+ [POLLINATIONS_HOST]: errResp(503, 'overloaded'),+ [LLM7_HOST]: errResp(502, 'bad gateway'),+ });await expect(llm.llmComplete({ system: 's', user: 'u' })).rejects.toMatchObject({status: 502,code: 'upstream_error',@@ -595,8 +600,8 @@ describe('llmComplete — failure modes', () => {},text: async () => 'not json',};- // Every reachable lane (groq + the two keyless rungs) returns garbage.- installFetch({ [GROQ_HOST]: badBody, [OVH_HOST]: badBody, [POLLINATIONS_HOST]: badBody });+ // Every reachable lane (groq + the three keyless rungs) returns garbage.+ installFetch({ [GROQ_HOST]: badBody, [OVH_HOST]: badBody, [POLLINATIONS_HOST]: badBody, [LLM7_HOST]: badBody });await expect(llm.llmComplete({ system: 's', user: 'u' })).rejects.toMatchObject({status: 502,code: 'upstream_bad_body',@@ -629,6 +634,7 @@ describe('llmComplete — failure modes', () => {[OPENROUTER_HOST]: openaiShape(''),[OVH_HOST]: openaiShape(''),[POLLINATIONS_HOST]: openaiShape(''),+ [LLM7_HOST]: openaiShape(''),});const out = await llm.llmComplete({ system: 's', user: 'u' });expect(out.text).toBe('');diff --git a/tests/chat-models.test.js b/tests/chat-models.test.jsindex b573a1d9a..5d930f33f 100644--- a/tests/chat-models.test.js+++ b/tests/chat-models.test.js@@ -86,11 +86,11 @@ describe('usableModels (route selector)', () => {describe('free-first ordering', () => {it('every free provider ranks ahead of every paid provider', () => {- // Free providers (Groq → OpenRouter → NVIDIA NIM) always lead; the paid- // keys (Anthropic, OpenAI, Grok) are last-resort backstops only reached- // when all three free lanes have failed.- expect(DEFAULT_PROVIDER_ORDER).toEqual(['groq', 'openrouter', 'nvidia', 'anthropic', 'openai', 'grok']);- const free = ['groq', 'openrouter', 'nvidia'];+ // Free providers (Groq, OpenRouter, NVIDIA NIM, SambaNova, Mistral,+ // Z.AI) always lead; the paid keys (Anthropic, OpenAI, Grok) are+ // last-resort backstops only reached when every free lane has failed.+ expect(DEFAULT_PROVIDER_ORDER).toEqual(['groq', 'openrouter', 'nvidia', 'sambanova', 'mistral', 'zai', 'anthropic', 'openai', 'grok']);+ const free = ['groq', 'openrouter', 'nvidia', 'sambanova', 'mistral', 'zai'];const paid = ['anthropic', 'openai', 'grok'];for (const f of free) {for (const p of paid) {@@ -122,7 +122,7 @@ describe('free-first ordering', () => {});it('anonymous callers are clamped to free tiers plus the credits-funded Vertex Gemini anchor', () => {- expect(ANON_PROVIDER_LIST).toEqual(['groq', 'openrouter', 'nvidia', 'vertex-gemini']);+ expect(ANON_PROVIDER_LIST).toEqual(['groq', 'openrouter', 'nvidia', 'sambanova', 'mistral', 'zai', 'vertex-gemini']);// The free third-party lanes lead; the funded Vertex anchor is the// last-resort rung so an anon caller never 503s just because every free// tier is rate-limited at once.diff --git a/tests/vertex-claude.test.js b/tests/vertex-claude.test.jsindex d8a3e232e..7a303b934 100644--- a/tests/vertex-claude.test.js+++ b/tests/vertex-claude.test.js@@ -168,13 +168,13 @@ describe('providerChain ordering under the four flag combinations', () => {// vertex-gemini reliability rung after the free lanes, plus groq#instant as// the free-tier capability step-down — both precede the paid backstops.it('off/off: no vertex-CLAUDE lane; free lanes → vertex-gemini → step-down → paid tail', () => {- expect(names()).toEqual(['groq', 'ovh', 'vertex-gemini', 'pollinations', 'groq#instant', 'anthropic']);+ expect(names()).toEqual(['groq', 'ovh', 'vertex-gemini', 'pollinations', 'llm7', 'groq#instant', 'anthropic']);});it('enabled/off: vertex claude is a paid backstop AHEAD of first-party anthropic, behind free lanes', () => {process.env.VERTEX_CLAUDE_ENABLED = '1';const n = names();- expect(n).toEqual(['groq', 'ovh', 'vertex-gemini', 'pollinations', 'groq#instant', 'vertex-anthropic', 'anthropic']);+ expect(n).toEqual(['groq', 'ovh', 'vertex-gemini', 'pollinations', 'llm7', 'groq#instant', 'vertex-anthropic', 'anthropic']);expect(n.indexOf('groq')).toBeLessThan(n.indexOf('vertex-anthropic'));expect(n.indexOf('vertex-anthropic')).toBeLessThan(n.indexOf('anthropic'));});@@ -191,7 +191,7 @@ describe('providerChain ordering under the four flag combinations', () => {it('primary flag alone (enabled unset) adds no vertex-claude lane', () => {process.env.VERTEX_CLAUDE_PRIMARY = '1';- expect(names()).toEqual(['groq', 'ovh', 'vertex-gemini', 'pollinations', 'groq#instant', 'anthropic']);+ expect(names()).toEqual(['groq', 'ovh', 'vertex-gemini', 'pollinations', 'llm7', 'groq#instant', 'anthropic']);});it('a caller BYOK key still leads even when vertex is primary', () => {