7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
fix(providers): retire the OpenCode free roster and stop calling Reka free (#1202, #1249) (#1265)
Tashfeen46de66184ffe
diff --git a/client/src/components/keys/shared.tsx b/client/src/components/keys/shared.tsxindex ae7cffaf..1827fc3a 100644--- a/client/src/components/keys/shared.tsx+++ b/client/src/components/keys/shared.tsx@@ -57,9 +57,9 @@ export const PLATFORMS: { value: Platform; label: string; url: string; keyless?:{ value: 'ovh', label: 'OVH AI Endpoints (no key needed)', url: 'https://endpoints.ai.cloud.ovh.net', keyless: true },{ value: 'llm7', label: 'LLM7 (anon ok)', url: 'https://llm7.io' },{ value: 'huggingface', label: 'HuggingFace Router', url: 'https://huggingface.co/settings/tokens' },- { value: 'opencode', label: 'OpenCode Zen (free key)', url: 'https://opencode.ai/auth' },+ { value: 'opencode', label: 'OpenCode Zen (paid models only)', url: 'https://opencode.ai/auth' },{ value: 'agnes', label: 'Agnes AI (free key)', url: 'https://platform.agnes-ai.com' },- { value: 'reka', label: 'Reka (free key)', url: 'https://platform.reka.ai' },+ { value: 'reka', label: 'Reka (prepaid credits)', url: 'https://platform.reka.ai' },{ value: 'siliconflow', label: 'SiliconFlow (image + TTS)', url: 'https://siliconflow.com' },{ value: 'routeway', label: 'Routeway (free key)', url: 'https://routeway.ai' },{ value: 'bazaarlink', label: 'BazaarLink (free key)', url: 'https://bazaarlink.ai' },diff --git a/docs/en/providers/01-supported-platforms.md b/docs/en/providers/01-supported-platforms.mdindex 45a4ec4a..353765f4 100644--- a/docs/en/providers/01-supported-platforms.md+++ b/docs/en/providers/01-supported-platforms.md@@ -36,10 +36,10 @@ Of the 43 built-in platforms, **10 use dedicated adapters** and **33 ride `OpenA| `pollinations` | Pollinations | Keyed | Native (`PollinationsProvider`) | `GET /v1/models` answers 200 even for revoked keys, so validation probes the authenticated `/account/key` instead (#608). || `llm7` | LLM7.io | Keyed (anonymous works for basic models) | OpenAI-compat | 100 req/hr free tier. || `huggingface` | Hugging Face Router | Keyed | OpenAI-compat | `router.huggingface.co` meta-router (re-added V13); recurring $0.10/mo router credit on the free tier. |-| `opencode` | OpenCode Zen | Keyed | OpenAI-compat | Trial-only promotional free roster, docs-confirmed ids seeded via `migrateModelsV18`. |+| `opencode` | OpenCode Zen | Keyed | OpenAI-compat | Free roster is locked to the OpenCode client since 2026-09 (403 FreeTierError, #1249) and disabled in the catalog; paid models only. || `ovh` | OVHcloud AI Endpoints | Keyless | OpenAI-compat | Anonymous tier: 2 req/min per IP per model (observed stricter); authenticated tier requires a Public Cloud project with payment method on file (`migrateModelsV26`). || `agnes` | Agnes AI | Keyed | OpenAI-compat | Proprietary models served at $0/token promotionally; ~30 concurrent requests before 429s; 60s timeout for reasoning TTFB. |-| `reka` | Reka | Keyed | OpenAI-compat | Free via recurring monthly credit grant (no card); balance dashboard-only. |+| `reka` | Reka | Keyed | OpenAI-compat | No free tier for new accounts since 2026-09: prepaid credits required (#1202). Accounts that still hold credit keep working; balance dashboard-only. || `siliconflow` | SiliconFlow | Keyed | OpenAI-compat | Registered mainly for FREE generative-media models (FLUX.1-schnell image, CosyVoice2 TTS) routed via `services/media.ts`. || `routeway` | Routeway | Keyed | OpenAI-compat | Requires browser-style User-Agent (Cloudflare rejects others with error 1010); free pool observed stricter (~5 rpm) than the documented 20 rpm / 200 rpd. || `bazaarlink` | BazaarLink | Keyed | OpenAI-compat | Only the `auto:free` route is cataloged — direct model ids are paid (#385). |diff --git a/docs/zh-cn/providers/01-supported-platforms.md b/docs/zh-cn/providers/01-supported-platforms.mdindex d8518cf4..c08270c6 100644--- a/docs/zh-cn/providers/01-supported-platforms.md+++ b/docs/zh-cn/providers/01-supported-platforms.md@@ -32,10 +32,10 @@| `pollinations` | Pollinations | 带密钥 | 原生(`PollinationsProvider`) | 即使密钥已被撤销,`GET /v1/models` 也返回 200,因此校验改为探测需鉴权的 `/account/key`(#608)。 || `llm7` | LLM7.io | 带密钥(基础模型可匿名) | OpenAI 兼容 | 免费档每小时 100 次请求。 || `huggingface` | Hugging Face Router | 带密钥 | OpenAI 兼容 | `router.huggingface.co` 元路由器(V13 重新加入);免费档每月循环发放 $0.10 路由额度。 |-| `opencode` | OpenCode Zen | 带密钥 | OpenAI 兼容 | 仅限试用的促销免费名册,经文档确认的 id 通过 `migrateModelsV18` 播种。 |+| `opencode` | OpenCode Zen | 带密钥 | OpenAI 兼容 | 自 2026-09 起免费名册仅限 OpenCode 客户端使用(403 FreeTierError,#1249),已在目录中停用;仅支持付费模型。 || `ovh` | OVHcloud AI Endpoints | 免密钥 | OpenAI 兼容 | 匿名档:每 IP 每模型每分钟 2 次请求(实测更严);鉴权档要求绑定了支付方式的 Public Cloud 项目(`migrateModelsV26`)。 || `agnes` | Agnes AI | 带密钥 | OpenAI 兼容 | 专有模型以 $0/词元促销提供;约 30 个并发请求后开始出现 429;为推理首字节设 60s 超时。 |-| `reka` | Reka | 带密钥 | OpenAI 兼容 | 通过每月循环的额度赠金免费(无需信用卡);余额只在仪表盘可见。 |+| `reka` | Reka | 带密钥 | OpenAI 兼容 | 自 2026-09 起新账号不再免费:需预付额度(#1202)。仍有余额的账号可继续使用;余额只在仪表盘可见。 || `siliconflow` | SiliconFlow | 带密钥 | OpenAI 兼容 | 主要为 FREE 生成媒体模型而注册(FLUX.1-schnell 图像、CosyVoice2 TTS),经由 `services/media.ts` 路由。 || `routeway` | Routeway | 带密钥 | OpenAI 兼容 | 要求浏览器风格的 User-Agent(Cloudflare 对其他值报错误 1010);实测免费池约 5 rpm,比文档写的 20 rpm / 200 rpd 更严。 || `bazaarlink` | BazaarLink | 带密钥 | OpenAI 兼容 | 只有 `auto:free` 路由进了目录——直接指定模型 id 是付费的(#385)。 |diff --git a/server/src/__tests__/providers/openai-compat.test.ts b/server/src/__tests__/providers/openai-compat.test.tsindex 9a974423..c0e5a8c1 100644--- a/server/src/__tests__/providers/openai-compat.test.ts+++ b/server/src/__tests__/providers/openai-compat.test.ts@@ -70,36 +70,6 @@ describe('OpenAICompatProvider', () => {expect(capturedBody.messages[0].role).toBe('user');});- it('evaluates function-valued extraHeaders once per request', async () => {- let issued = 0;- const dynamic = new OpenAICompatProvider({- platform: 'opencode',- name: 'Zen',- baseUrl: 'https://api.test.com/v1',- extraHeaders: () => ({ 'x-opencode-session': `session-${++issued}` }),- });- const seen: string[] = [];- vi.spyOn(global, 'fetch').mockImplementation(async (_url, init) => {- seen.push((init as any).headers['x-opencode-session']);- return {- ok: true,- json: () => Promise.resolve({- id: 'test-id',- object: 'chat.completion',- created: 123,- model: 'test-model',- choices: [{ index: 0, message: { role: 'assistant', content: 'hi' }, finish_reason: 'stop' }],- usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 },- }),- } as any;- });-- await dynamic.chatCompletion('my-key', [{ role: 'user', content: 'one' }], 'test-model');- await dynamic.chatCompletion('my-key', [{ role: 'user', content: 'two' }], 'test-model');-- expect(seen).toEqual(['session-1', 'session-2']);- });-describe('Moonshot assistant `partial` prefill flag (#1038)', () => {beforeEach(() => {// The custom-platform SSRF guard resolves public hosts before everydiff --git a/server/src/providers/index.ts b/server/src/providers/index.tsindex bc52e4e2..057f51b6 100644--- a/server/src/providers/index.ts+++ b/server/src/providers/index.ts@@ -1,5 +1,4 @@import type { Platform } from '@freellmapi/shared/types.js';-import { randomUUID } from 'node:crypto';import type { BaseProvider } from './base.js';import { GoogleProvider } from './google.js';import { OpenAICompatProvider } from './openai-compat.js';@@ -258,51 +257,15 @@ register(new OpenAICompatProvider({// (no card required — billing only applies to paid models). The free roster is// trial-only and prompts/outputs may be used to improve the models, so we seed// just the docs-confirmed free IDs (migrateModelsV18) with conservative limits.-// The Console gateway additionally expects the request to look like it came-// from the OpenCode client: without x-opencode-session it answers-// MissingSessionID, and the free roster answers "OpenCode's free tier can only-// be used in OpenCode" even with a valid key. Fresh session/request ids per-// call mirror the CLI (both the free roster and the paid Go plan were verified-// against this header set).-// The UA advertises the newest published OpenCode release so an upstream-// version check cannot age into a block. The npm registry (the artifact the-// CLI itself ships from) is the cheapest source; a failed lookup keeps the-// last known version and the built-in fallback covers a cold first boot.-const OPENCODE_NPM_LATEST = 'https://registry.npmjs.org/opencode-ai/latest';-const OPENCODE_UA_FALLBACK_VERSION = '1.18.30';-const OPENCODE_UA_VERSION_TTL_MS = 12 * 60 * 60 * 1000;-let openCodeUaVersion = OPENCODE_UA_FALLBACK_VERSION;-let openCodeUaVersionCheckedAt = 0;--function refreshOpenCodeUaVersion(): void {- if (process.env.VITEST) return;- const now = Date.now();- if (now - openCodeUaVersionCheckedAt < OPENCODE_UA_VERSION_TTL_MS) return;- openCodeUaVersionCheckedAt = now; // stamp first so parallel calls share one lookup- void fetch(OPENCODE_NPM_LATEST, { signal: AbortSignal.timeout(4000) })- .then(res => (res.ok ? res.json() : null))- .then((doc: unknown) => {- const version = (doc as { version?: unknown } | null)?.version;- if (typeof version === 'string' && /^\d+\.\d+\.\d+$/.test(version)) openCodeUaVersion = version;- })- .catch(() => { /* keep the last known version */ });-}--function openCodeZenHeaders(): Record<string, string> {- refreshOpenCodeUaVersion();- return {- 'User-Agent': `opencode/${openCodeUaVersion} ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14`,- 'x-opencode-client': 'cli',- 'x-opencode-project': 'global',- 'x-opencode-session': randomUUID(),- 'x-opencode-request': randomUUID(),- };-}+// Since 2026-09 the free roster is locked to the OpenCode client (#1249): every+// free model answers 403 FreeTierError "OpenCode's free tier can only be used+// from within OpenCode" on a valid key, and sending the OpenCode client headers+// (#1204, reverted) does not change that. The catalog disables the free rows;+// the provider stays registered for keys on OpenCode's paid models.register(new OpenAICompatProvider({platform: 'opencode',name: 'OpenCode Zen',baseUrl: 'https://opencode.ai/zen/v1',- extraHeaders: openCodeZenHeaders,}));// OVHcloud AI Endpoints — OpenAI-compatible. Two free modes: anonymous@@ -345,9 +308,12 @@ register(new OpenAICompatProvider({// $0.0, please pay with fiat or send tao". The "free" tier requires a// non-zero balance, which conflicts with the project's no-card criterion.-// Reka — OpenAI-compatible (api.reka.ai/v1). Live-probed 2026-06-17: free via a-// recurring monthly credit grant (no card; key from platform.reka.ai), billed-// calls succeed with no 402. The OpenAI-compatible /v1/models lists two models:+// Reka — OpenAI-compatible (api.reka.ai/v1). No longer free for new accounts+// (#1202): Reka's FAQ now requires prepaid credits and a $0 balance answers+// P001 Insufficient Balance. Accounts that still hold credit keep working+// (both models answered 200 on 2026-09-17), so the provider stays registered;+// the old `reka-flash` id 404s and is disabled in the catalog.+// The OpenAI-compatible /v1/models lists two models:// reka-flash-3 (text reasoning) and reka-edge-2603 (natively multimodal —// accepts image/video input). Balance is dashboard-only (no credits API).// Catalog rows live in the catalog (premium → age into free); they are NOTdiff --git a/server/src/providers/openai-compat.ts b/server/src/providers/openai-compat.tsindex 6c40372e..c5aff35d 100644--- a/server/src/providers/openai-compat.ts+++ b/server/src/providers/openai-compat.ts@@ -68,7 +68,7 @@ export class OpenAICompatProvider extends BaseProvider {readonly platform: Platform;readonly name: string;private readonly baseUrl: string;- private readonly extraHeaders: Record<string, string> | (() => Record<string, string>);+ private readonly extraHeaders: Record<string, string>;private readonly validateUrl?: string;/** Per-provider HTTP timeout override. OpenAI-compatible gateways often buffer* non-streaming responses until generation completes, and reasoning models can@@ -86,7 +86,7 @@ export class OpenAICompatProvider extends BaseProvider {platform: Platform;name: string;baseUrl: string;- extraHeaders?: Record<string, string> | (() => Record<string, string>);+ extraHeaders?: Record<string, string>;validateUrl?: string;timeoutMs?: number;keyless?: boolean;@@ -169,14 +169,6 @@ export class OpenAICompatProvider extends BaseProvider {return this.keyless ? {} : { 'Authorization': `Bearer ${apiKey}` };}- /** Extra headers for one upstream request. The function form is evaluated- * once per request so a gateway that expects fresh per-request ids (OpenCode- * Zen's `x-opencode-session`) does not have to live with values frozen at- * registration time. */- private requestHeaders(): Record<string, string> {- return typeof this.extraHeaders === 'function' ? this.extraHeaders() : this.extraHeaders;- }-/** Requesty's Leanstral route rejects greedy sampling when temperature=0.* Omitting that value and supplying a neutral top_p keeps the caller's intent* deterministic enough while using the provider's supported sampling path. */@@ -286,7 +278,7 @@ export class OpenAICompatProvider extends BaseProvider {headers: {...this.authHeader(apiKey),'Content-Type': 'application/json',- ...this.requestHeaders(),+ ...this.extraHeaders,},body: JSON.stringify({model: modelId,@@ -415,7 +407,7 @@ export class OpenAICompatProvider extends BaseProvider {headers: {...this.authHeader(apiKey),'Content-Type': 'application/json',- ...this.requestHeaders(),+ ...this.extraHeaders,},body: JSON.stringify({model: modelId,@@ -524,7 +516,7 @@ export class OpenAICompatProvider extends BaseProvider {method: 'GET',headers: {...this.authHeader(apiKey),- ...this.requestHeaders(),+ ...this.extraHeaders,},// 'request' bounds: a catalog body that hangs mid-transfer must not// stall the health cycle past the deadline.diff --git a/shared/types.ts b/shared/types.tsindex f390441b..3305ec4e 100644--- a/shared/types.ts+++ b/shared/types.ts@@ -121,8 +121,8 @@ export type Platform =// platform.agnes-ai.com (no card).| 'agnes'// Reka — OpenAI-compatible. Native multimodal models (reka-edge takes- // image/video); free via a recurring monthly credit grant, key from- // platform.reka.ai (no card).+ // image/video). New accounts need prepaid credits (#1202); key from+ // platform.reka.ai.| 'reka'// SiliconFlow — OpenAI-compatible. Registered for its FREE generative-media// models (FLUX.1-schnell image, CosyVoice2 TTS) routed via services/media.ts;