Skip to content

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 Qianfan, Volcengine Ark, LongCat and iFlytek Spark (#936)

Tashfeendf1000a6cd8f
diff --git a/client/src/components/keys/shared.tsx b/client/src/components/keys/shared.tsx
index 01172597..648c56d8 100644
--- a/client/src/components/keys/shared.tsx
+++ b/client/src/components/keys/shared.tsx
@@ -63,6 +63,14 @@ export const PLATFORMS: { value: Platform; label: string; url: string; keyless?:
{ value: 'anyapi', label: 'AnyAPI (free key)', url: 'https://anyapi.ai' },
{ value: 'modelscope', label: 'ModelScope (free key, needs Aliyun cn binding)', url: 'https://modelscope.cn/my/myaccesstoken' },
{ value: 'aihorde', label: 'AI Horde (no key needed, slow)', url: 'https://aihorde.net/register', keyless: true },
+ // Chinese domestic providers. All four gate API access behind real-name
+ // verification on the cloud account, so the label says so up front rather
+ // than letting a user mint a key that 401s on every call (the ModelScope
+ // lesson, #581). LongCat is the one that takes an overseas email signup.
+ { value: 'qianfan', label: 'Baidu Qianfan (free ERNIE, needs cn real-name)', url: 'https://console.bce.baidu.com/qianfan/overview' },
+ { value: 'volcengine', label: 'Volcengine Ark (free daily, needs cn real-name)', url: 'https://console.volcengine.com/ark' },
+ { value: 'longcat', label: 'LongCat (free daily, email signup ok)', url: 'https://longcat.chat/platform' },
+ { value: 'xfyun', label: 'iFlytek Spark (free Lite, needs cn real-name)', url: 'https://console.xfyun.cn' },
]
// 'custom' is configured through its own form (base URL + model), not the
diff --git a/client/src/lib/routing.ts b/client/src/lib/routing.ts
index 4e1a45c8..24574812 100644
--- a/client/src/lib/routing.ts
+++ b/client/src/lib/routing.ts
@@ -309,6 +309,10 @@ export const platformColors: Record<string, string> = {
anyapi: '#0891b2',
modelscope: '#624aff',
aihorde: '#dc2626',
+ qianfan: '#2932e1',
+ volcengine: '#00b8d9',
+ longcat: '#ffd100',
+ xfyun: '#1f6fd0',
}
// ── Grouped (unified) rendering ──────────────────────────────────────────────
diff --git a/server/src/__tests__/providers/cn-providers.test.ts b/server/src/__tests__/providers/cn-providers.test.ts
new file mode 100644
index 00000000..7c6b16e7
--- /dev/null
+++ b/server/src/__tests__/providers/cn-providers.test.ts
@@ -0,0 +1,69 @@
+import { describe, expect, it } from 'vitest';
+import { getProvider } from '../../providers/index.js';
+import { AUTH_JSON_PROVIDER_MAP, detectPlatform } from '../../lib/key-parser.js';
+import type { Platform } from '@freellmapi/shared/types.js';
+
+// Chinese domestic providers (#922/#923/#924). The failure this file guards
+// against is a HALF-registered platform: the original PRs registered the
+// provider and the Platform type but skipped the key-parser and the Keys page,
+// so the provider existed on the server and was unreachable for a user — no way
+// to add a key through the dashboard, and no way to import one from a .env.
+// Registration is only useful when every entry point agrees, so assert them
+// together.
+
+const CN_PLATFORMS: { platform: Platform; baseUrl: string; envPrefixes: string[]; jsonAliases: string[] }[] = [
+ {
+ platform: 'qianfan',
+ baseUrl: 'https://qianfan.baidubce.com/v2',
+ envPrefixes: ['QIANFAN_', 'BAIDU_', 'ERNIE_'],
+ jsonAliases: ['qianfan', 'baidu', 'ernie'],
+ },
+ {
+ platform: 'volcengine',
+ baseUrl: 'https://ark.cn-beijing.volces.com/api/v3',
+ envPrefixes: ['VOLCENGINE_', 'VOLC_', 'ARK_', 'DOUBAO_'],
+ jsonAliases: ['volcengine', 'volc', 'ark', 'doubao'],
+ },
+ {
+ platform: 'longcat',
+ baseUrl: 'https://api.longcat.chat/openai/v1',
+ envPrefixes: ['LONGCAT_'],
+ jsonAliases: ['longcat'],
+ },
+ {
+ platform: 'xfyun',
+ baseUrl: 'https://spark-api-open.xf-yun.com/v1',
+ envPrefixes: ['XFYUN_', 'SPARK_', 'IFLYTEK_'],
+ jsonAliases: ['xfyun', 'spark', 'iflytek'],
+ },
+];
+
+describe('Chinese domestic providers: registration', () => {
+ it.each(CN_PLATFORMS)('$platform is registered as an OpenAI-compatible provider', ({ platform }) => {
+ const provider = getProvider(platform);
+ expect(provider).toBeDefined();
+ expect(provider!.platform).toBe(platform);
+ });
+
+ // The base URL is the one thing a typo makes silently useless: every request
+ // 404s at a plausible-looking host. These four are transcribed from each
+ // vendor's own OpenAI-compatibility doc.
+ it.each(CN_PLATFORMS)('$platform points at the documented OpenAI-compatible base URL', ({ platform, baseUrl }) => {
+ const provider = getProvider(platform) as unknown as { baseUrl: string };
+ expect(provider.baseUrl).toBe(baseUrl);
+ });
+});
+
+describe('Chinese domestic providers: key import', () => {
+ it.each(CN_PLATFORMS)('$platform resolves from its .env prefixes', ({ platform, envPrefixes }) => {
+ for (const prefix of envPrefixes) {
+ expect(detectPlatform(prefix)).toBe(platform);
+ }
+ });
+
+ it.each(CN_PLATFORMS)('$platform resolves from its auth.json aliases', ({ platform, jsonAliases }) => {
+ for (const alias of jsonAliases) {
+ expect(AUTH_JSON_PROVIDER_MAP[alias]).toBe(platform);
+ }
+ });
+});
diff --git a/server/src/lib/key-parser.ts b/server/src/lib/key-parser.ts
index 10a8fae0..1edde2e7 100644
--- a/server/src/lib/key-parser.ts
+++ b/server/src/lib/key-parser.ts
@@ -82,6 +82,17 @@ export const PREFIX_MAP: Record<string, string> = {
ANYAPI_: 'anyapi',
ANY_API_: 'anyapi',
AIHORDE_: 'aihorde',
+ QIANFAN_: 'qianfan',
+ BAIDU_: 'qianfan',
+ ERNIE_: 'qianfan',
+ VOLCENGINE_: 'volcengine',
+ VOLC_: 'volcengine',
+ ARK_: 'volcengine',
+ DOUBAO_: 'volcengine',
+ LONGCAT_: 'longcat',
+ XFYUN_: 'xfyun',
+ SPARK_: 'xfyun',
+ IFLYTEK_: 'xfyun',
};
export const AUTH_JSON_PROVIDER_MAP: Record<string, string> = {
@@ -115,6 +126,17 @@ export const AUTH_JSON_PROVIDER_MAP: Record<string, string> = {
'model-scope': 'modelscope',
anyapi: 'anyapi',
'any-api': 'anyapi',
+ qianfan: 'qianfan',
+ baidu: 'qianfan',
+ ernie: 'qianfan',
+ volcengine: 'volcengine',
+ volc: 'volcengine',
+ ark: 'volcengine',
+ doubao: 'volcengine',
+ longcat: 'longcat',
+ xfyun: 'xfyun',
+ spark: 'xfyun',
+ iflytek: 'xfyun',
};
export function detectPlatform(prefix: string): string | null {
diff --git a/server/src/providers/index.ts b/server/src/providers/index.ts
index e5b1445b..07a46339 100644
--- a/server/src/providers/index.ts
+++ b/server/src/providers/index.ts
@@ -395,6 +395,46 @@ register(new OpenAICompatProvider({
// provider-quota.ts keys on response headers, never on that message text.
register(new ModelScopeProvider());
+// ── Chinese domestic providers (#922/#923/#924) ─────────────────────────────
+// Plain OpenAI-compatible Bearer endpoints, so no dedicated provider class is
+// needed. Every one of these requires Chinese real-name verification on the
+// cloud account before a key serves traffic (LongCat aside — it takes an email
+// signup from outside mainland China). Catalog rows live in the hosted catalog,
+// never in a migration, so a free user cannot pick them up from a binary
+// upgrade ahead of the premium window.
+
+// Baidu Qianfan (百度千帆). ERNIE-Speed / ERNIE-Lite / ERNIE-Tiny are free via
+// pay-as-you-go billing, bounded by rate limits rather than a token balance.
+register(new OpenAICompatProvider({
+ platform: 'qianfan',
+ name: 'Baidu Qianfan',
+ baseUrl: 'https://qianfan.baidubce.com/v2',
+}));
+
+// Volcengine Ark (火山方舟, ByteDance). Doubao models on a recurring daily
+// per-model free reward quota (2M tokens/day/model for individual developers).
+register(new OpenAICompatProvider({
+ platform: 'volcengine',
+ name: 'Volcengine Ark',
+ baseUrl: 'https://ark.cn-beijing.volces.com/api/v3',
+}));
+
+// LongCat (Meituan / 美团). Daily free quota; the platform also speaks the
+// Anthropic wire format at /anthropic, which we do not use here.
+register(new OpenAICompatProvider({
+ platform: 'longcat',
+ name: 'LongCat',
+ baseUrl: 'https://api.longcat.chat/openai/v1',
+}));
+
+// iFlytek Spark (讯飞星火). Auth is the console APIPassword as a Bearer token;
+// the Lite model is the free one.
+register(new OpenAICompatProvider({
+ platform: 'xfyun',
+ name: 'iFlytek Spark',
+ baseUrl: 'https://spark-api-open.xf-yun.com/v1',
+}));
+
// AI Horde — free, community-powered inference (volunteer workers) via an
// OpenAI-compatible proxy. Dedicated AIHordeProvider (not OpenAICompatProvider)
// because the proxy is queue-based and diverges from the OpenAI contract:
diff --git a/server/src/routes/keys.ts b/server/src/routes/keys.ts
index 0e5f1bda..d44f9b1e 100644
--- a/server/src/routes/keys.ts
+++ b/server/src/routes/keys.ts
@@ -31,7 +31,8 @@ const PLATFORMS = [
'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',
+ 'routeway', 'bazaarlink', 'ainative', 'aion', 'anyapi', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'modelscope',
+ 'qianfan', 'volcengine', 'longcat', 'xfyun', 'aihorde', 'custom',
] as const;
const ALLOWED_IMPORT_EXTENSIONS = new Set(['.env', '.json', '.jsonc', '.md', '.txt', '.csv']);
diff --git a/shared/types.ts b/shared/types.ts
index 31524acb..83a561da 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -139,6 +139,38 @@ export type Platform =
// verification — tokens mint without binding, then every call 401s. Catalog
// rows land after community testing confirms per-model behavior (#581).
| 'modelscope'
+ // ── Chinese domestic providers (#922/#923/#924) ────────────────────────────
+ // All four need Chinese real-name verification (实名认证) on the cloud account
+ // before a key will serve traffic, the same wall ModelScope hits above.
+ // LongCat is the exception worth knowing: its platform accepts an email
+ // signup from outside mainland China.
+ //
+ // Baidu Qianfan (百度千帆) — OpenAI-compatible (https://qianfan.baidubce.com/v2).
+ // The ERNIE-Speed / ERNIE-Lite / ERNIE-Tiny series are free indefinitely via
+ // pay-as-you-go billing rather than a token pool, so the ceiling is rate
+ // limits, not a balance. Baidu calls the arrangement "long-term". Real-name
+ // auth (individual or enterprise) required.
+ | 'qianfan'
+ // Volcengine Ark (火山方舟, ByteDance) — OpenAI-compatible
+ // (https://ark.cn-beijing.volces.com/api/v3). Individual developers get a
+ // RECURRING daily per-model free reward quota (raised from 500K to 2M
+ // tokens/day/model), on top of a one-time 500K new-user grant. The strongest
+ // recurring free tier of the four.
+ | 'volcengine'
+ // LongCat (Meituan / 美团) — OpenAI-compatible
+ // (https://api.longcat.chat/openai/v1); also exposes an Anthropic-compatible
+ // surface at /anthropic. Free tier is daily; the figure quoted at platform
+ // launch was 100K tokens/day. Meituan has ANNOUNCED a 50M tokens/day
+ // Flash-Lite free tier but it was described as a future plan, so it is not
+ // treated as live here.
+ | 'longcat'
+ // iFlytek Spark (讯飞星火) — OpenAI-compatible
+ // (https://spark-api-open.xf-yun.com/v1), Bearer auth using the console's
+ // APIPassword (not the APIKey/APISecret pair the older WebSocket API used).
+ // The Lite model (model id `lite`) is documented as free to call; iFlytek
+ // does not publish a token ceiling or a QPS figure for it, so neither is
+ // claimed here.
+ | 'xfyun'
// AI Horde — free, community-powered inference (volunteer workers) via an
// OpenAI-compatible proxy (https://oai.aihorde.net/v1). Queue-based, so calls
// can take tens of seconds; no tool support; usage is reported as kudos, not