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 B.AI gateway (#918)
Tashfeen00268be4eb5d
diff --git a/client/src/components/keys/shared.tsx b/client/src/components/keys/shared.tsxindex 83287d8a..01172597 100644--- a/client/src/components/keys/shared.tsx+++ b/client/src/components/keys/shared.tsx@@ -29,6 +29,7 @@ export const PLATFORMS: { value: Platform; label: string; url: string; keyless?:{ value: 'google', label: 'Google AI Studio', url: 'https://aistudio.google.com/apikey' },{ value: 'groq', label: 'Groq', url: 'https://console.groq.com/keys' },{ value: 'cerebras', label: 'Cerebras', url: 'https://cloud.cerebras.ai' },+ { value: 'bai', label: 'B.AI (promotional free model)', url: 'https://b.ai' },{ value: 'nvidia', label: 'NVIDIA NIM', url: 'https://build.nvidia.com/settings/api-keys' },{ value: 'mistral', label: 'Mistral', url: 'https://console.mistral.ai/api-keys/' },{ value: 'openrouter', label: 'OpenRouter', url: 'https://openrouter.ai/keys' },diff --git a/client/src/lib/routing.ts b/client/src/lib/routing.tsindex 48db90c9..4e1a45c8 100644--- a/client/src/lib/routing.ts+++ b/client/src/lib/routing.ts@@ -284,6 +284,7 @@ export const platformColors: Record<string, string> = {google: '#4285f4',groq: '#f55036',cerebras: '#8b5cf6',+ bai: '#111827',nvidia: '#76b900',mistral: '#f59e0b',openrouter: '#ec4899',diff --git a/server/src/__tests__/lib/key-parser.test.ts b/server/src/__tests__/lib/key-parser.test.tsindex e42e539d..cd69f3af 100644--- a/server/src/__tests__/lib/key-parser.test.ts+++ b/server/src/__tests__/lib/key-parser.test.ts@@ -60,6 +60,8 @@ describe('key parser', () => {expect(detectPlatform('MODELSCOPE_')).toBe('modelscope');expect(detectPlatform('ANYAPI_')).toBe('anyapi');expect(detectPlatform('ANY_API_')).toBe('anyapi');+ expect(detectPlatform('BAI_')).toBe('bai');+ expect(detectPlatform('B_AI_')).toBe('bai');expect(detectPlatform('SAMBANOVA_')).toBeNull();});@@ -73,6 +75,7 @@ describe('key parser', () => {expect(AUTH_JSON_PROVIDER_MAP['orca-router']).toBe('orcarouter');expect(AUTH_JSON_PROVIDER_MAP['model-scope']).toBe('modelscope');expect(AUTH_JSON_PROVIDER_MAP['any-api']).toBe('anyapi');+ expect(AUTH_JSON_PROVIDER_MAP['b-ai']).toBe('bai');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/openai-compat.test.ts b/server/src/__tests__/providers/openai-compat.test.tsindex 7c31810b..255de183 100644--- a/server/src/__tests__/providers/openai-compat.test.ts+++ b/server/src/__tests__/providers/openai-compat.test.ts@@ -498,6 +498,7 @@ describe('OpenAICompatProvider - platform instances', () => {const platforms = [{ platform: 'groq', name: 'Groq', baseUrl: 'https://api.groq.com/openai/v1' },{ platform: 'cerebras', name: 'Cerebras', baseUrl: 'https://api.cerebras.ai/v1' },+ { platform: 'bai', name: 'B.AI', baseUrl: 'https://api.b.ai/v1' },{ platform: 'anyapi', name: 'AnyAPI', baseUrl: 'https://api.anyapi.ai/v1' },{ platform: 'nvidia', name: 'NVIDIA NIM', baseUrl: 'https://integrate.api.nvidia.com/v1' },{ platform: 'mistral', name: 'Mistral', baseUrl: 'https://api.mistral.ai/v1' },diff --git a/server/src/__tests__/routes/proxy-stream-integrity.test.ts b/server/src/__tests__/routes/proxy-stream-integrity.test.tsindex 31537a65..8254f95e 100644--- a/server/src/__tests__/routes/proxy-stream-integrity.test.ts+++ b/server/src/__tests__/routes/proxy-stream-integrity.test.ts@@ -55,7 +55,7 @@ function mockUpstream(script: Array<{ body: string; status?: number }>) {const urlStr = typeof url === 'string' ? url : url.toString();// Only intercept provider upstreams; the test's own localhost request// and anything else goes through.- if (!/api\.groq\.com|openrouter\.ai|api\.cohere|generativelanguage|integrate\.api\.nvidia|api\.cerebras|api\.mistral|router\.huggingface|api\.cloudflare|models\.github|open\.bigmodel|api\.llm7|api\.kilo|gen\.pollinations|ollama\.com|opencode\.ai|api\.aionlabs\.ai|router\.requesty\.ai|api\.navy|router\.bynara\.id/.test(urlStr)) {+ if (!/api\.groq\.com|openrouter\.ai|api\.cohere|generativelanguage|integrate\.api\.nvidia|api\.cerebras|api\.b\.ai|api\.mistral|router\.huggingface|api\.cloudflare|models\.github|open\.bigmodel|api\.llm7|api\.kilo|gen\.pollinations|ollama\.com|opencode\.ai|api\.aionlabs\.ai|router\.requesty\.ai|api\.navy|router\.bynara\.id/.test(urlStr)) {return origFetch(url as any, init);}const reqBody = JSON.parse(String((init as RequestInit).body));diff --git a/server/src/lib/key-parser.ts b/server/src/lib/key-parser.tsindex 9906843c..10a8fae0 100644--- a/server/src/lib/key-parser.ts+++ b/server/src/lib/key-parser.ts@@ -42,6 +42,8 @@ export const PREFIX_MAP: Record<string, string> = {GEMINI_: 'google',GROQ_: 'groq',CEREBRAS_: 'cerebras',+ BAI_: 'bai',+ B_AI_: 'bai',NVIDIA_: 'nvidia',MISTRAL_: 'mistral',OPENROUTER_: 'openrouter',@@ -86,6 +88,8 @@ export const AUTH_JSON_PROVIDER_MAP: Record<string, string> = {gemini: 'google',google: 'google',groq: 'groq',+ bai: 'bai',+ 'b-ai': 'bai',openrouter: 'openrouter','ollama-cloud': 'ollama',ollama: 'ollama',diff --git a/server/src/providers/index.ts b/server/src/providers/index.tsindex 0442c61f..e5b1445b 100644--- a/server/src/providers/index.ts+++ b/server/src/providers/index.ts@@ -33,6 +33,15 @@ register(new OpenAICompatProvider({baseUrl: 'https://api.cerebras.ai/v1',}));+// 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.+register(new OpenAICompatProvider({+ platform: 'bai',+ name: 'B.AI',+ baseUrl: 'https://api.b.ai/v1',+}));+// AnyAPI - OpenAI-compatible gateway (anyapi.ai). Free tier (checked against// anyapi.ai/pricing 2026-08-10): $0, no card, recurring — but the binding limit// is 100K TOKENS PER DAY, and only "free and basic" models are in scope. AnyAPIdiff --git a/server/src/routes/keys.ts b/server/src/routes/keys.tsindex 6c17ae64..0e5f1bda 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', 'nvidia', 'mistral',+ 'google', 'groq', 'cerebras', 'bai', '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', 'modelscope', 'aihorde', 'custom',diff --git a/server/src/services/provider-quota.ts b/server/src/services/provider-quota.tsindex 1ce508d9..54285d74 100644--- a/server/src/services/provider-quota.ts+++ b/server/src/services/provider-quota.ts@@ -115,6 +115,7 @@ function inferPoolForPlatform(platform: Platform, modelId?: string | null): striif (platform === 'google') return 'google::project';if (platform === 'groq') return 'groq::account';if (platform === 'cerebras') return 'cerebras::shared';+ if (platform === 'bai') return 'bai::promo';if (platform === 'sambanova') return 'sambanova::shared';if (platform === 'nvidia') return 'nvidia::credit-pool';if (platform === 'mistral') return 'mistral::experiment-pool';@@ -153,7 +154,7 @@ function inferPoolForPlatform(platform: Platform, modelId?: string | null): stri}function isSharedPool(platform: Platform): boolean {- return ['openrouter', 'google', 'groq', 'cerebras', 'sambanova', 'nvidia', 'mistral', 'github', 'cohere', 'cloudflare', 'zhipu', 'ollama', 'kilo', 'pollinations', 'llm7', 'huggingface', 'opencode', 'routeway', 'bazaarlink', 'ainative', 'aion', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'anyapi', 'modelscope', 'aihorde'].includes(platform);+ return ['openrouter', 'google', 'groq', 'cerebras', 'bai', 'sambanova', 'nvidia', 'mistral', 'github', 'cohere', 'cloudflare', 'zhipu', 'ollama', 'kilo', 'pollinations', 'llm7', 'huggingface', 'opencode', 'routeway', 'bazaarlink', 'ainative', 'aion', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'anyapi', 'modelscope', 'aihorde'].includes(platform);}type HeaderSpec = { metric: QuotaMetric; limit: string; remaining?: string; reset?: string; strategy?: QuotaResetStrategy };diff --git a/shared/types.ts b/shared/types.tsindex 446d0e8b..31524acb 100644--- a/shared/types.ts+++ b/shared/types.ts@@ -60,6 +60,9 @@ export type Platform =| 'google'| 'groq'| 'cerebras'+ // B.AI — OpenAI-compatible gateway. Its catalog row is a live-tested,+ // limited-time 0-credit promotion, not a recurring free allowance.+ | 'bai'// AnyAPI — OpenAI-compatible gateway. Free tier is $0/no card/recurring but// capped at 100K tokens/day over "free and basic" models only; no RPM/RPD is// published. Catalog rows live in the hosted catalog (premium now, free after