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
feat(providers): add ElectronHub and Experiential Labs (#1169)
Tashfeen709676521127
diff --git a/client/src/components/keys/shared.tsx b/client/src/components/keys/shared.tsxindex cff2db03..68906d83 100644--- a/client/src/components/keys/shared.tsx+++ b/client/src/components/keys/shared.tsx@@ -30,6 +30,8 @@ export const PLATFORMS: { value: Platform; label: string; url: string; keyless?:{ value: 'groq', label: 'Groq', url: 'https://console.groq.com/keys' },{ value: 'cerebras', label: 'Cerebras', url: 'https://cloud.cerebras.ai' },{ value: 'sail', label: 'Sail Research ($5 monthly with payment method)', url: 'https://app.sailresearch.com' },+ { value: 'electronhub', label: 'ElectronHub (shared weekly credits)', url: 'https://app.electronhub.ai' },+ { value: 'experiential', label: 'Experiential Labs (shared monthly credits)', url: 'https://platform.experientiallabs.ai' },{ value: 'bai', label: 'B.AI (promotional free model)', url: 'https://b.ai' },{ value: 'radeon', label: 'AMD Radeon Cloud (free shared models)', url: 'https://developer.amd.com.cn/radeon/tokenfactory' },{ value: 'nvidia', label: 'NVIDIA NIM', url: 'https://build.nvidia.com/settings/api-keys' },diff --git a/client/src/lib/routing.ts b/client/src/lib/routing.tsindex e870d81d..c446a122 100644--- a/client/src/lib/routing.ts+++ b/client/src/lib/routing.ts@@ -380,6 +380,8 @@ export const platformColors: Record<string, string> = {groq: '#f55036',cerebras: '#8b5cf6',sail: '#0ea5e9',+ electronhub: '#6366f1',+ experiential: '#14b8a6',bai: '#111827',radeon: '#ed1c24',nvidia: '#76b900',diff --git a/docs/en/providers/01-supported-platforms.md b/docs/en/providers/01-supported-platforms.mdindex 67beb7cf..45a4ec4a 100644--- a/docs/en/providers/01-supported-platforms.md+++ b/docs/en/providers/01-supported-platforms.md@@ -2,13 +2,13 @@# Supported platforms-The `Platform` union in [`shared/types.ts` (line 59)](../../../shared/types.ts) is the single source of truth for platform identity; the runtime registry in [`server/src/providers/index.ts`](../../../server/src/providers/index.ts) must match it. The union currently declares **43 members**:+The `Platform` union in [`shared/types.ts` (line 59)](../../../shared/types.ts) is the single source of truth for platform identity; the runtime registry in [`server/src/providers/index.ts`](../../../server/src/providers/index.ts) must match it. The union currently declares **45 members**:-- **41 built-in platforms** registered as adapters at startup,-- plus the **`custom`** placeholder (a real OpenAI-compatible adapter built per API key, since its base URL is user-supplied), giving **42 entries** in the registry map,+- **43 built-in platforms** registered as adapters at startup,+- plus the **`custom`** placeholder (a real OpenAI-compatible adapter built per API key, since its base URL is user-supplied), giving **44 entries** in the registry map,- plus **`sambanova`**, retained in the type union but no longer registered — it was dropped in V23 (June 2026) when its free tier was permanently retired (every chat call returns 402 "payment method required" once the one-time $5 trial credit lapses).-Of the 41 built-in platforms, **8 use dedicated native adapters** and **33 ride `OpenAICompatProvider`** against a provider-specific base URL. Three platforms are registered keyless (`kilo`, `ovh`, and `aihorde`, which auto-configures with its documented anonymous sentinel key). The public catalog headline is smaller than the union because several registered gateways keep their free rosters in the hosted catalog rather than shipping them to every binary.+Of the 43 built-in platforms, **10 use dedicated adapters** and **33 ride `OpenAICompatProvider`** directly against a provider-specific base URL. Three platforms are registered keyless (`kilo`, `ovh`, and `aihorde`, which auto-configures with its documented anonymous sentinel key). The public catalog headline is smaller than the union because several registered gateways keep their free rosters in the hosted catalog rather than shipping them to every binary.## Catalog@@ -17,6 +17,8 @@ Of the 41 built-in platforms, **8 use dedicated native adapters** and **33 ride| `google` | Google Gemini | Keyed | Native (`GoogleProvider`) | Gemini wire format; 60s default timeout because Gemma reasoning variants take 20–60s on cold start. || `groq` | Groq | Keyed | OpenAI-compat | Standard compatible endpoint at `api.groq.com/openai/v1`. || `cerebras` | Cerebras | Keyed | OpenAI-compat | `api.cerebras.ai/v1`. |+| `electronhub` | ElectronHub | Keyed | OpenAI-compat subclass | Shared weekly credit pool; validates against `/v1/user/me`, rejects HTTP-200 proxy-error banners. [Funding and integration notes](04-recurring-credit-gateways.md). |+| `experiential` | Experiential Labs | Keyed | OpenAI-compat subclass | Shared monthly credit pool; authenticated `/v1/models`, model-specific Claude sampling compatibility. [Funding and account-verification notes](04-recurring-credit-gateways.md). || `sail` | Sail Research | Keyed (payment method required for recurring credit) | Native (`SailProvider`) | Stable `/v1/responses` integration submits background jobs and polls them to completion; flex-only models use the `flex` completion window. Sail grants $5 in monthly credits while a payment method is attached, then charges usage beyond that credit. || `bai` | B.AI | Keyed | OpenAI-compat | Gateway added in #918; only catalog row is a limited-time 0-credit promo, kept in the hosted catalog. || `anyapi` | AnyAPI | Keyed | OpenAI-compat | Free tier $0/no card/recurring, capped at 100K tokens/day over "free and basic" models; no RPM/RPD published (#772). Model ids arrive via catalog-sync, never seeded blind. |diff --git a/docs/en/providers/04-recurring-credit-gateways.md b/docs/en/providers/04-recurring-credit-gateways.mdnew file mode 100644index 00000000..61d5ff12--- /dev/null+++ b/docs/en/providers/04-recurring-credit-gateways.md@@ -0,0 +1,44 @@+# ElectronHub and Experiential Labs++Both providers use bearer-authenticated Chat Completions at their `/v1` base+URLs. Model availability is managed in the signed Oracle catalog, not seeded+in application migrations. The existing Premium-immediate / Free-after-30-days+catalog policy is unchanged.++| Provider ID | Base URL | Key-validation endpoint | Free-plan funding |+| --- | --- | --- | --- |+| `electronhub` | `https://api.electronhub.ai/v1` | `GET /v1/user/me` | $0.25 shared weekly credits, not monthly; non-premium credit-backed routes only |+| `experiential` | `https://api.experientiallabs.ai/v1` | `GET /v1/models` | Published 500 shared monthly credits at $0.01 each ($5); confirm account eligibility/balance in its dashboard |++Checked 2026-09-06: 23 ElectronHub and 25 Experiential model IDs returned valid+text. ElectronHub's account API showed a Free subscription and spending from+weekly credits with no purchased-credit balance. Experiential authentication+and inference worked, but account balance is web-session-only; successful+inference alone does not establish whether an account used monthly, welcome,+or purchased credits. Neither provider is unlimited or grants credits per model.++ElectronHub's model list is public, so validation uses its authenticated account+endpoint. Its dedicated compatibility subclass rejects the observed proxy-error+banner embedded in HTTP-200 responses, including split SSE chunks. The other+seven tested ElectronHub candidates were excluded from catalog additions.++Experiential's compatibility subclass omits fixed-temperature and unsupported+top-p knobs on the specific Claude routes that reject them. This was caught+by a live adapter test using normal dashboard sampling settings, not merely a+minimal direct API request. Other models retain their supported settings.++Key imports accept `ELECTRONHUB_API_KEY`, `ELECTRON_HUB_API_KEY`,+`EXPERIENTIAL_API_KEY`, `EXPERIENTIALLABS_API_KEY`,+`EXPERIENTIAL_LABS_API_KEY`, and `EXPLABS_API_KEY`.++No provider billing settings are changed by the adapters. They observe shared+quota pools and provider response headers; they do not invent per-model credit+or token allowances. Set spend controls with the provider before enabling paid+top-ups or bring-your-own-provider-key routing.++Sources: [ElectronHub credits](https://docs.electronhub.ai/billing/credits),+[model access](https://docs.electronhub.ai/billing/model-access),+[account API](https://docs.electronhub.ai/api-reference/usage),+[Experiential pricing](https://www.experientiallabs.ai/pricing),+[billing](https://platform.experientiallabs.ai/docs/billing),+[API reference](https://platform.experientiallabs.ai/docs/reference).diff --git a/server/src/__tests__/lib/key-parser.test.ts b/server/src/__tests__/lib/key-parser.test.tsindex 10e2c42b..d98d1451 100644--- a/server/src/__tests__/lib/key-parser.test.ts+++ b/server/src/__tests__/lib/key-parser.test.ts@@ -70,6 +70,12 @@ describe('key parser', () => {expect(detectPlatform('AMD_TOKENFACTORY_')).toBe('radeon');expect(detectPlatform('SAIL_')).toBe('sail');expect(detectPlatform('SAIL_RESEARCH_')).toBe('sail');+ expect(detectPlatform('ELECTRONHUB_')).toBe('electronhub');+ expect(detectPlatform('ELECTRON_HUB_')).toBe('electronhub');+ expect(detectPlatform('EXPERIENTIAL_')).toBe('experiential');+ expect(detectPlatform('EXPERIENTIALLABS_')).toBe('experiential');+ expect(detectPlatform('EXPERIENTIAL_LABS_')).toBe('experiential');+ expect(detectPlatform('EXPLABS_')).toBe('experiential');expect(detectPlatform('SAMBANOVA_')).toBeNull();});@@ -88,6 +94,9 @@ describe('key parser', () => {expect(AUTH_JSON_PROVIDER_MAP['radeon-cloud']).toBe('radeon');expect(AUTH_JSON_PROVIDER_MAP['amd-tokenfactory']).toBe('radeon');expect(AUTH_JSON_PROVIDER_MAP['sail-research']).toBe('sail');+ expect(AUTH_JSON_PROVIDER_MAP['electron-hub']).toBe('electronhub');+ expect(AUTH_JSON_PROVIDER_MAP['experiential-labs']).toBe('experiential');+ expect(AUTH_JSON_PROVIDER_MAP['explabs']).toBe('experiential');const result = parseAuthJson(JSON.stringify({credential_pool: {gemini: [{ id: '1', label: 'Gemini', auth_type: 'api_key', access_token: 'AIza-test' }],diff --git a/server/src/__tests__/providers/reasoning-timeouts.test.ts b/server/src/__tests__/providers/reasoning-timeouts.test.tsindex 04b6dae1..39b3a90f 100644--- a/server/src/__tests__/providers/reasoning-timeouts.test.ts+++ b/server/src/__tests__/providers/reasoning-timeouts.test.ts@@ -22,6 +22,8 @@ describe('reasoning-model chat timeouts', () => {['zhipu', 60_000],['agnes', 60_000],['opencode', 60_000],+ ['experiential', 60_000],+ ['electronhub', 90_000],['ollama', 120_000], // pre-existing bump; keep it from regressing too// Radeon Cloud documents a ten-minute non-streaming and stream-gap limit.['radeon', 600_000],diff --git a/server/src/__tests__/providers/recurring-credit-gateways.test.ts b/server/src/__tests__/providers/recurring-credit-gateways.test.tsnew file mode 100644index 00000000..84f883d8--- /dev/null+++ b/server/src/__tests__/providers/recurring-credit-gateways.test.ts@@ -0,0 +1,148 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import type { ChatCompletionChunk } from '@freellmapi/shared/types.js';+import { getProvider, hasProvider } from '../../providers/index.js';+import { isRetryableError } from '../../lib/error-classify.js';++const gateways = [+ { platform: 'electronhub', base: 'https://api.electronhub.ai/v1', validate: 'https://api.electronhub.ai/v1/user/me' },+ { platform: 'experiential', base: 'https://api.experientiallabs.ai/v1', validate: 'https://api.experientiallabs.ai/v1/models' },+] as const;++function completion(content = 'OK') {+ return {+ id: 'chatcmpl-test', object: 'chat.completion', created: 1, model: 'tested-model',+ choices: [{ index: 0, message: { role: 'assistant', content }, finish_reason: 'stop' }],+ usage: { prompt_tokens: 9, completion_tokens: 1, total_tokens: 10 },+ };+}++function stream(parts: string[]) {+ const base = { id: 'chatcmpl-test', object: 'chat.completion.chunk', created: 1, model: 'tested-model' };+ const chunks = [+ { ...base, choices: [{ index: 0, delta: { role: 'assistant' }, finish_reason: null }] },+ ...parts.map(content => ({ ...base, choices: [{ index: 0, delta: { content }, finish_reason: null }] })),+ { ...base, choices: [{ index: 0, delta: {}, finish_reason: 'stop' }] },+ ];+ return new Response(chunks.map(chunk => `data: ${JSON.stringify(chunk)}\n\n`).join('') + 'data: [DONE]\n\n', {+ headers: { 'Content-Type': 'text/event-stream' },+ });+}++describe('recurring-credit gateway adapters', () => {+ afterEach(() => vi.restoreAllMocks());++ for (const gateway of gateways) {+ it(`${gateway.platform}: registers, authenticates, forwards the requested model and preserves usage`, async () => {+ expect(hasProvider(gateway.platform)).toBe(true);+ const provider = getProvider(gateway.platform)!;+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(JSON.stringify(completion())));+ const result = await provider.chatCompletion('test-key', [{ role: 'user', content: 'Reply OK' }], 'tested-model', {+ max_tokens: 256, temperature: 0.2,+ tools: [{ type: 'function', function: { name: 'lookup', parameters: { type: 'object', properties: {} } } }],+ });+ const [url, init] = fetch.mock.calls[0];+ expect(url).toBe(`${gateway.base}/chat/completions`);+ expect(new Headers(init?.headers).get('authorization')).toBe('Bearer test-key');+ expect(JSON.parse(String(init?.body))).toMatchObject({ model: 'tested-model', max_tokens: 256, temperature: 0.2 });+ expect(JSON.parse(String(init?.body)).tools[0].function.name).toBe('lookup');+ expect(result.choices[0].message.content).toBe('OK');+ expect(result.usage.total_tokens).toBe(10);+ expect(result._routed_via).toEqual({ platform: gateway.platform, model: 'tested-model' });+ });++ it(`${gateway.platform}: validates against an authenticated read-only endpoint`, async () => {+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(new Response('{}'));+ await expect(getProvider(gateway.platform)!.validateKey('test-key')).resolves.toBe(true);+ expect(fetch.mock.calls[0][0]).toBe(gateway.validate);+ expect(fetch.mock.calls[0][1]?.method).toBe('GET');+ expect(new Headers(fetch.mock.calls[0][1]?.headers).get('authorization')).toBe('Bearer test-key');+ });++ it.each([401, 403])(`${gateway.platform}: rejects an invalid credential (%s)`, async status => {+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response(JSON.stringify({ error: { message: 'Invalid API key' } }), { status }));+ await expect(getProvider(gateway.platform)!.validateKey('bad-test-key')).resolves.toMatchObject({ valid: false });+ });++ it(`${gateway.platform}: streams through the same endpoint with bearer auth`, async () => {+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(stream(['O', 'K']));+ const output: ChatCompletionChunk[] = [];+ for await (const chunk of getProvider(gateway.platform)!.streamChatCompletion('test-key', [{ role: 'user', content: 'Hi' }], 'tested-model')) output.push(chunk);+ expect(output.flatMap(chunk => chunk.choices).map(choice => choice.delta.content ?? '').join('')).toBe('OK');+ expect(fetch.mock.calls[0][0]).toBe(`${gateway.base}/chat/completions`);+ expect(JSON.parse(String(fetch.mock.calls[0][1]?.body)).stream).toBe(true);+ expect(new Headers(fetch.mock.calls[0][1]?.headers).get('authorization')).toBe('Bearer test-key');+ });++ it(`${gateway.platform}: preserves provider-requested backoff`, async () => {+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response(JSON.stringify({ error: { message: 'Rate limit reached' } }), {+ status: 429, headers: { 'Retry-After': '180' },+ }));+ await expect(getProvider(gateway.platform)!.chatCompletion('test-key', [], 'tested-model')).rejects.toMatchObject({ status: 429, retryAfterMs: 180_000 });+ });+ }++ it('ElectronHub treats its HTTP-200 proxy-error banner as a retryable 502, without leaking the body', async () => {+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response(JSON.stringify(completion('### **Proxy error (HTTP 404 Not Found)**\nPrivate upstream details'))));+ const error = await getProvider('electronhub')!.chatCompletion('test-key', [], 'tested-model').catch(e => e);+ expect(error.status).toBe(502);+ expect(isRetryableError(error)).toBe(true);+ expect(error.message).not.toContain('Private upstream');+ });++ it.each(['claude-fable-5', 'claude-opus-5', 'claude-sonnet-5', 'claude-opus-4.7', 'claude-opus-4.8'])(+ 'Experiential omits unsupported temperature and top_p for %s', async model => {+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(JSON.stringify(completion())));+ await getProvider('experiential')!.chatCompletion('test-key', [], model, { temperature: 0.7, top_p: 0.95, max_tokens: 256 });+ const body = JSON.parse(String(fetch.mock.calls[0][1]?.body));+ expect(body).not.toHaveProperty('temperature');+ expect(body).not.toHaveProperty('top_p');+ expect(body.max_tokens).toBe(256);+ },+ );++ it('Experiential uses the same model-specific sampling policy while streaming', async () => {+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(stream(['OK']));+ for await (const _chunk of getProvider('experiential')!.streamChatCompletion('test-key', [], 'claude-opus-5', { temperature: 0.7, top_p: 0.95 })) { /* drain */ }+ const body = JSON.parse(String(fetch.mock.calls[0][1]?.body));+ expect(body).not.toHaveProperty('temperature');+ expect(body).not.toHaveProperty('top_p');+ });++ it.each(['claude-opus-4.6', 'claude-sonnet-4.6'])(+ 'Experiential omits the restricted reasoning top_p for %s', async model => {+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(JSON.stringify(completion())));+ await getProvider('experiential')!.chatCompletion('test-key', [], model, { temperature: 0.7, top_p: 0.95 });+ const body = JSON.parse(String(fetch.mock.calls[0][1]?.body));+ expect(body).not.toHaveProperty('temperature');+ expect(body).not.toHaveProperty('top_p');+ },+ );++ it.each([+ [{ temperature: 0.7, top_p: 0.95 }, { temperature: 0.7 }],+ [{ top_p: 0.95 }, { top_p: 0.95 }],+ ])('Experiential never sends competing sampling knobs to legacy Claude routes', async (options, expected) => {+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(JSON.stringify(completion())));+ await getProvider('experiential')!.chatCompletion('test-key', [], 'claude-haiku-4.5', options);+ const body = JSON.parse(String(fetch.mock.calls[0][1]?.body));+ expect(body).toMatchObject(expected);+ expect(body.temperature !== undefined && body.top_p !== undefined).toBe(false);+ });++ it('ElectronHub catches a proxy-error banner split across SSE chunks before yielding content', async () => {+ vi.spyOn(global, 'fetch').mockResolvedValue(stream(['### **Pro', 'xy error (HTTP ', '404 Not Found)**']));+ const output: ChatCompletionChunk[] = [];+ const consume = async () => {+ for await (const chunk of getProvider('electronhub')!.streamChatCompletion('test-key', [], 'tested-model')) output.push(chunk);+ };+ await expect(consume()).rejects.toMatchObject({ status: 502 });+ expect(output).toEqual([]);+ });++ it('ElectronHub preserves normal markdown, including a short heading-prefix response', async () => {+ vi.spyOn(global, 'fetch').mockResolvedValue(stream(['###']));+ const output: ChatCompletionChunk[] = [];+ for await (const chunk of getProvider('electronhub')!.streamChatCompletion('test-key', [], 'tested-model')) output.push(chunk);+ expect(output.flatMap(chunk => chunk.choices).map(choice => choice.delta.content ?? '').join('')).toBe('###');+ });+});diff --git a/server/src/__tests__/routes/keys.test.ts b/server/src/__tests__/routes/keys.test.tsindex 4b5ce1c9..58afdfda 100644--- a/server/src/__tests__/routes/keys.test.ts+++ b/server/src/__tests__/routes/keys.test.ts@@ -153,6 +153,16 @@ describe('Keys API', () => {expect(status).toBe(400);});+ it.each(['electronhub', 'experiential'])('accepts a %s key without seeding gated model rows', async platform => {+ const { status, body } = await request(app, 'POST', '/api/keys', {+ platform, key: 'not-a-real-test-key-12345', label: 'Gateway test',+ });+ expect(status).toBe(201);+ expect(body.platform).toBe(platform);+ expect(body.modelsAvailable).toBe(0);+ expect(getDb().prepare('SELECT COUNT(*) AS n FROM models WHERE platform = ?').get(platform)).toEqual({ n: 0 });+ });+it('POST /api/keys rejects missing key', async () => {const { status } = await request(app, 'POST', '/api/keys', {platform: 'groq',diff --git a/server/src/__tests__/services/provider-quota.test.ts b/server/src/__tests__/services/provider-quota.test.tsindex cac619db..e88b1915 100644--- a/server/src/__tests__/services/provider-quota.test.ts+++ b/server/src/__tests__/services/provider-quota.test.ts@@ -40,6 +40,11 @@ describe('provider-quota: pool inference', () => {it('buckets shared-pool providers per account and openrouter free vs account', () => {expect(inferQuotaPoolKey('groq')).toBe('groq::account');+ expect(inferQuotaPoolKey('electronhub', 'qwen3.8-flash')).toBe('electronhub::weekly-credit');+ expect(inferQuotaPoolKey('electronhub', 'gpt-oss-120b')).toBe('electronhub::weekly-credit');+ expect(inferQuotaPoolKey('electronhub', 'some-model:free')).toBe('electronhub::daily-free');+ expect(inferQuotaPoolKey('experiential', 'glm-5.3')).toBe('experiential::monthly-credit');+ expect(inferQuotaPoolKey('experiential', 'gpt-5.6-sol')).toBe('experiential::monthly-credit');expect(inferQuotaPoolKey('openrouter', 'meta-llama/llama-3.1-8b-instruct:free')).toBe('openrouter::free');expect(inferQuotaPoolKey('openrouter', 'openai/gpt-4o')).toBe('openrouter::account');// AnyAPI's 100K tokens/day is one account-wide budget, so every model on@@ -242,6 +247,20 @@ describe('provider-quota: parse from response headers (shared parseRetryAfterMs)quotaPoolKey: 'radeon::daily-free', limit: 10, remaining: 7.5,});});++ it('uses ElectronHub account headers without inventing per-model credit limits', () => {+ const response = new Response(null, { headers: {+ 'x-ratelimit-limit': '5', 'x-ratelimit-remaining': '4', 'x-ratelimit-reset': '1788690000',+ } });+ const observations = parseQuotaObservationsFromResponse(response, {+ platform: 'electronhub', keyId: 9, modelId: 'qwen3.8-flash',+ });+ expect(observations.find(o => o.metric === 'requests')).toMatchObject({+ quotaPoolKey: 'electronhub::weekly-credit', limit: 5, remaining: 4,+ resetAt: new Date(1788690000000).toISOString(),+ });+ expect(observations.some(o => o.metric === 'credits')).toBe(false);+ });});describe('provider-quota: reset_at replenishment on read (#453)', () => {diff --git a/server/src/lib/key-parser.ts b/server/src/lib/key-parser.tsindex 26354c55..c5c5fb20 100644--- a/server/src/lib/key-parser.ts+++ b/server/src/lib/key-parser.ts@@ -45,6 +45,12 @@ export const PREFIX_MAP: Record<string, string> = {SAIL_: 'sail',SAILRESEARCH_: 'sail',SAIL_RESEARCH_: 'sail',+ ELECTRONHUB_: 'electronhub',+ ELECTRON_HUB_: 'electronhub',+ EXPERIENTIAL_: 'experiential',+ EXPERIENTIALLABS_: 'experiential',+ EXPERIENTIAL_LABS_: 'experiential',+ EXPLABS_: 'experiential',BAI_: 'bai',B_AI_: 'bai',RADEON_: 'radeon',@@ -111,6 +117,12 @@ export const AUTH_JSON_PROVIDER_MAP: Record<string, string> = {sail: 'sail','sail-research': 'sail',sailresearch: 'sail',+ electronhub: 'electronhub',+ 'electron-hub': 'electronhub',+ experiential: 'experiential',+ experientiallabs: 'experiential',+ 'experiential-labs': 'experiential',+ explabs: 'experiential',bai: 'bai','b-ai': 'bai',radeon: 'radeon',diff --git a/server/src/providers/electronhub.ts b/server/src/providers/electronhub.tsnew file mode 100644index 00000000..1036b539--- /dev/null+++ b/server/src/providers/electronhub.ts@@ -0,0 +1,73 @@+import type { ChatCompletionChunk, ChatCompletionResponse, ChatMessage } from '@freellmapi/shared/types.js';+import type { CompletionOptions } from './base.js';+import type { QuotaObservationContext } from '../services/provider-quota.js';+import { contentToString } from '../lib/content.js';+import { OpenAICompatProvider } from './openai-compat.js';++// Observed on two broken upstream routes despite HTTP 200. Keep the match+// anchored and narrow: ordinary answers discussing proxy errors are valid.+const PROXY_ERROR_PREFIX = '### **Proxy error (HTTP ';++function proxyError(): Error & { status: number } {+ // Do not echo the upstream body: it may contain provider credential details.+ return Object.assign(new Error('ElectronHub upstream proxy error returned inside a completion'), { status: 502 });+}++export class ElectronHubProvider extends OpenAICompatProvider {+ constructor() {+ super({+ platform: 'electronhub',+ name: 'ElectronHub',+ baseUrl: 'https://api.electronhub.ai/v1',+ // /models is public and would accept an invalid key. This read-only+ // endpoint authenticates without spending an inference request.+ validateUrl: 'https://api.electronhub.ai/v1/user/me',+ timeoutMs: 90_000,+ });+ }++ override async chatCompletion(+ apiKey: string,+ messages: ChatMessage[],+ modelId: string,+ options?: CompletionOptions,+ quotaContext?: QuotaObservationContext,+ ): Promise<ChatCompletionResponse> {+ const response = await super.chatCompletion(apiKey, messages, modelId, options, quotaContext);+ if (response.choices.some(choice => contentToString(choice.message.content).trimStart().startsWith(PROXY_ERROR_PREFIX))) {+ throw proxyError();+ }+ return response;+ }++ override async *streamChatCompletion(+ apiKey: string,+ messages: ChatMessage[],+ modelId: string,+ options?: CompletionOptions,+ quotaContext?: QuotaObservationContext,+ ): AsyncGenerator<ChatCompletionChunk> {+ const pending: ChatCompletionChunk[] = [];+ let prefix = '';+ let checked = false;+ for await (const chunk of super.streamChatCompletion(apiKey, messages, modelId, options, quotaContext)) {+ if (checked) {+ yield chunk;+ continue;+ }+ pending.push(chunk);+ const choice = chunk.choices.find(item => item.index === 0);+ prefix += contentToString(choice?.delta.content);+ const text = prefix.trimStart();+ if (text.startsWith(PROXY_ERROR_PREFIX)) throw proxyError();+ // Buffer only a possible error-heading prefix, including split SSE+ // chunks. Tool calls and ordinary text pass through immediately.+ if ((!text || PROXY_ERROR_PREFIX.startsWith(text)) &&+ !choice?.delta.tool_calls?.length && prefix.length < 256 && pending.length < 64) continue;+ checked = true;+ yield* pending;+ pending.length = 0;+ }+ yield* pending;+ }+}diff --git a/server/src/providers/experiential.ts b/server/src/providers/experiential.tsnew file mode 100644index 00000000..a9ee9ab6--- /dev/null+++ b/server/src/providers/experiential.ts@@ -0,0 +1,36 @@+import type { CompletionOptions } from './base.js';+import { OpenAICompatProvider } from './openai-compat.js';++// Verified against /api/models on 2026-09-06; Opus 5 also returned a live 400+// for temperature=0.7. These reasoning routes fix temperature at 1. Omission+// lets the gateway apply its supported default, rather than forwarding the+// dashboard's normal 0.7 into a guaranteed rejection. No catalog rows seeded.+const FIXED_TEMPERATURE_MODELS = new Set([+ 'claude-fable-5', 'claude-opus-5', 'claude-sonnet-5',+ 'claude-opus-4.6', 'claude-opus-4.7', 'claude-opus-4.8', 'claude-sonnet-4.6',+]);++export class ExperientialProvider extends OpenAICompatProvider {+ constructor() {+ super({+ platform: 'experiential',+ name: 'Experiential Labs',+ baseUrl: 'https://api.experientiallabs.ai/v1',+ });+ }++ protected override samplingForModel(modelId: string, options?: CompletionOptions) {+ const sampling = super.samplingForModel(modelId, options);+ // 4.6 reasoning routes additionally constrain top_p to [0.99, 1]; the+ // newer routes reject it entirely. Omit both on the fixed-temperature+ // routes. Other Claude routes accept either knob, but reject both together+ // (live-reproduced on Haiku 4.5); prefer the requested temperature there.+ const fixed = FIXED_TEMPERATURE_MODELS.has(modelId);+ const competingClaudeSampling = modelId.startsWith('claude-') &&+ sampling.temperature !== undefined && sampling.topP !== undefined;+ return {+ temperature: fixed ? undefined : sampling.temperature,+ topP: fixed || competingClaudeSampling ? undefined : sampling.topP,+ };+ }+}diff --git a/server/src/providers/index.ts b/server/src/providers/index.tsindex 5321591c..b965d06a 100644--- a/server/src/providers/index.ts+++ b/server/src/providers/index.ts@@ -9,6 +9,8 @@ import { ModelScopeProvider } from './modelscope.js';import { PollinationsProvider } from './pollinations.js';import { ZhipuProvider } from './zhipu.js';import { SailProvider } from './sail.js';+import { ElectronHubProvider } from './electronhub.js';+import { ExperientialProvider } from './experiential.js';const providers = new Map<Platform, BaseProvider>();@@ -43,6 +45,11 @@ register(new OpenAICompatProvider({// stay in Oracle so the existing Premium-now / Free-after-30-days gate applies.register(new SailProvider());+// Free-plan grants are shared wallets, not free credits per model. Eligibility+// and tested model rows belong in Oracle, never in bundled DB migrations.+register(new ElectronHubProvider());+register(new ExperientialProvider());+// B.AI — OpenAI-compatible gateway. Provider support is first-class, but the// only free catalog row currently published is a limited-time 0-credit promo;// keep commercial eligibility in the hosted catalog rather than seeding it.diff --git a/server/src/providers/openai-compat.ts b/server/src/providers/openai-compat.tsindex 8a6d1fac..d982efdd 100644--- a/server/src/providers/openai-compat.ts+++ b/server/src/providers/openai-compat.ts@@ -151,7 +151,7 @@ export class OpenAICompatProvider extends BaseProvider {/** 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. */- private samplingForModel(modelId: string, options?: CompletionOptions): {+ protected samplingForModel(modelId: string, options?: CompletionOptions): {temperature: number | undefined;topP: number | undefined;} {diff --git a/server/src/routes/keys.ts b/server/src/routes/keys.tsindex 122836db..005171ff 100644--- a/server/src/routes/keys.ts+++ b/server/src/routes/keys.ts@@ -28,7 +28,7 @@ export const keysRouter = Router();// was dropped in V4 and re-added in V13 via the router.huggingface.co route.// SambaNova was dropped in V23 (free tier permanently retired).const PLATFORMS = [- 'google', 'groq', 'cerebras', 'sail', 'bai', 'radeon', 'nvidia', 'mistral',+ 'google', 'groq', 'cerebras', 'sail', 'electronhub', 'experiential', 'bai', 'radeon', 'nvidia', 'mistral','openrouter', 'github', 'cohere', 'cloudflare', 'zhipu', 'ollama','kilo', 'pollinations', 'llm7', 'huggingface', 'opencode', 'ovh', 'agnes', 'reka', 'siliconflow','routeway', 'bazaarlink', 'ainative', 'aion', 'anyapi', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'unorouter', 'xkiro', 'modelscope',diff --git a/server/src/services/provider-quota.ts b/server/src/services/provider-quota.tsindex e5a41783..51b197fc 100644--- a/server/src/services/provider-quota.ts+++ b/server/src/services/provider-quota.ts@@ -116,6 +116,8 @@ function inferPoolForPlatform(platform: Platform, modelId?: string | null): striif (platform === 'groq') return 'groq::account';if (platform === 'cerebras') return 'cerebras::shared';if (platform === 'sail') return 'sail::monthly-credit';+ if (platform === 'electronhub') return normalizedModelId.endsWith(':free') ? 'electronhub::daily-free' : 'electronhub::weekly-credit';+ if (platform === 'experiential') return 'experiential::monthly-credit';if (platform === 'bai') return 'bai::promo';if (platform === 'radeon') return 'radeon::daily-free';if (platform === 'sambanova') return 'sambanova::shared';@@ -164,12 +166,18 @@ function inferPoolForPlatform(platform: Platform, modelId?: string | null): stri}function isSharedPool(platform: Platform): boolean {+ if (platform === 'electronhub' || platform === 'experiential') return true;return ['openrouter', 'google', 'groq', 'cerebras', 'sail', 'bai', 'radeon', 'sambanova', 'nvidia', 'mistral', 'github', 'cohere', 'cloudflare', 'zhipu', 'ollama', 'kilo', 'pollinations', 'llm7', 'huggingface', 'opencode', 'routeway', 'bazaarlink', 'ainative', 'aion', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'unorouter', 'xkiro', 'anyapi', 'modelscope', 'aihorde'].includes(platform);}type HeaderSpec = { metric: QuotaMetric; limit: string; remaining?: string; reset?: string; strategy?: QuotaResetStrategy };const HEADER_SPECS: Partial<Record<Platform, HeaderSpec[]>> = {+ // Live-observed account-wide rolling-minute headers; no invented limits or+ // conversion of credit grants into token budgets.+ electronhub: [+ { metric: 'requests', limit: 'x-ratelimit-limit', remaining: 'x-ratelimit-remaining', reset: 'x-ratelimit-reset', strategy: 'provider_reported' },+ ],groq: [{ metric: 'requests', limit: 'x-ratelimit-limit-requests', remaining: 'x-ratelimit-remaining-requests', reset: 'x-ratelimit-reset-requests', strategy: 'provider_reported' },{ metric: 'tokens', limit: 'x-ratelimit-limit-tokens', remaining: 'x-ratelimit-remaining-tokens', reset: 'x-ratelimit-reset-tokens', strategy: 'provider_reported' },diff --git a/shared/types.ts b/shared/types.tsindex 59e8f765..19f33410 100644--- a/shared/types.ts+++ b/shared/types.ts@@ -68,6 +68,10 @@ export type Platform =// monthly when a payment method is attached; usage beyond the grant is// pay-as-you-go. Background polling is required for its flex-only models.| 'sail'+ // Hosted gateways; model rows are delivered by the signed catalog only.+ // ElectronHub renews weekly credits; Experiential renews monthly credits.+ | 'electronhub'+ | 'experiential'// B.AI — OpenAI-compatible gateway. Its catalog row is a live-tested,// limited-time 0-credit promotion, not a recurring free allowance.| 'bai'