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 Plugsky and ElectronHub speech support (#1441)

Tashfeendbac4f3c07ac
diff --git a/client/src/components/keys/shared.tsx b/client/src/components/keys/shared.tsx
index d5ff3e4e..30117aca 100644
--- a/client/src/components/keys/shared.tsx
+++ b/client/src/components/keys/shared.tsx
@@ -30,6 +30,7 @@ export const PLATFORMS: { value: Platform; label: string; url: string; keyless?:
{ value: 'aclide', label: 'ACLIDE (shared monthly credits)', url: 'https://aclide.com/en/dashboard/api-keys' },
{ value: 'speka', label: 'Speka ($1 shared monthly credits)', url: 'https://speka.me/dashboard/keys' },
{ value: 'typhoon', label: 'Typhoon (free research API)', url: 'https://playground.opentyphoon.ai' },
+ { value: 'plugsky', label: 'Plugsky (free chat aliases)', url: 'https://plugsky.com/dashboard' },
{ value: 'llmtr', label: 'LLMTR (daily free-model quotas)', url: 'https://llmtr.com' },
{ value: 'gizmo', label: 'Gizmo (monthly free-model requests)', url: 'https://gizmoplatforms.com/developers' },
{ value: 'blockrun', label: 'BlockRun (zero-priced models)', url: 'https://user.blockrun.ai/dashboard/keys' },
diff --git a/client/src/lib/routing.ts b/client/src/lib/routing.ts
index ae109dc4..fcc1577e 100644
--- a/client/src/lib/routing.ts
+++ b/client/src/lib/routing.ts
@@ -406,6 +406,7 @@ export const platformColors: Record<string, string> = {
aclide: '#6366f1',
speka: '#0d9488',
typhoon: '#e11d48',
+ plugsky: '#0284c7',
llmtr: '#0f766e',
gizmo: '#7c3aed',
blockrun: '#2563eb',
diff --git a/docs/providers/plugsky.md b/docs/providers/plugsky.md
new file mode 100644
index 00000000..cf8d6694
--- /dev/null
+++ b/docs/providers/plugsky.md
@@ -0,0 +1,25 @@
+# Plugsky and ElectronHub speech
+
+Plugsky uses `https://plugsky.com/v1` with a bearer API key. Add the key on
+Keys → Plugsky, import `PLUGSKY_API_KEY`, or use the `plugsky` auth.json entry.
+Validation calls the authenticated, read-only `/plugsky/usage` endpoint, not
+the public `/models` list. Transient failures remain inconclusive.
+
+The permanent Free plan includes `plugsky-micro` and `plugsky-lite`, separately
+from the wider seven-day trial. These are provider aliases with changeable
+upstreams, not guarantees of particular model weights. Free chat is subject to
+shared fair use; tools and paid/trial-only routes are not advertised as free.
+See [Plugsky documentation](https://plugsky.com/docs).
+
+ElectronHub speech uses `/v1/audio/speech` with the existing ElectronHub key.
+The adapter supports MP3/WAV containers, defaults Gemini voices to `Kore` and
+HUMAIN to `sara`, and preserves explicit provider voice names. Gemini may return
+WAV when MP3 is requested; the returned MIME type follows the actual bytes.
+HTTP-200 JSON/text errors and empty audio are rejected. Speech shares the
+existing weekly free credit wallet, rather than getting a separate grant.
+See [speech API](https://docs.electronhub.ai/api-reference/audio/speech) and
+[credit policy](https://docs.electronhub.ai/billing/credits).
+
+All model rows arrive through the signed catalog, with no database seeds or
+automatic discovery. Premium/live and Free/30-day eligibility logic is unchanged.
+Older installations must update the application to use these adapters.
diff --git a/server/src/__tests__/providers/plugsky.test.ts b/server/src/__tests__/providers/plugsky.test.ts
new file mode 100644
index 00000000..bc059274
--- /dev/null
+++ b/server/src/__tests__/providers/plugsky.test.ts
@@ -0,0 +1,77 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { PlugskyProvider, PLUGSKY_BASE_URL } from '../../providers/plugsky.js';
+import { getProvider } from '../../providers/index.js';
+import { AUTH_JSON_PROVIDER_MAP, parseKeysFromFile } from '../../lib/key-parser.js';
+
+const model = 'plugsky-micro';
+const json = (body: unknown, status = 200, headers = {}) => new Response(JSON.stringify(body), { status, headers });
+
+describe('Plugsky', () => {
+ afterEach(() => vi.restoreAllMocks());
+
+ it('registers the keyed provider and explicit key-file aliases', () => {
+ expect(getProvider('plugsky')).toBeInstanceOf(PlugskyProvider);
+ expect(getProvider('plugsky')!.keyless).toBe(false);
+ expect(parseKeysFromFile('PLUGSKY_API_KEY=sk-live-test', 'keys.env').keys[0].platform).toBe('plugsky');
+ expect(AUTH_JSON_PROVIDER_MAP.plugsky).toBe('plugsky');
+ });
+
+ it('validates through authenticated usage without consuming inference', async () => {
+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(json({ data: [] }));
+ expect(await new PlugskyProvider().validateKey('test-key')).toBe(true);
+ const [url, init] = fetch.mock.calls[0];
+ expect(url).toBe(`${PLUGSKY_BASE_URL}/plugsky/usage`);
+ expect(init?.method).toBe('GET');
+ expect(new Headers(init?.headers).get('authorization')).toBe('Bearer test-key');
+ expect(fetch).toHaveBeenCalledTimes(1);
+ });
+
+ it.each([401, 403])('rejects authentication failure %s', async status => {
+ vi.spyOn(global, 'fetch').mockResolvedValue(json({ error: { message: 'Invalid API key' } }, status));
+ await expect(new PlugskyProvider().validateKey('bad-key')).resolves.toMatchObject({ valid: false });
+ });
+
+ it.each([402, 429, 503])('does not treat HTTP %s as a validated or invalid key', async status => {
+ vi.spyOn(global, 'fetch').mockResolvedValue(json({}, status, { 'Retry-After': '19' }));
+ await expect(new PlugskyProvider().validateKey('test-key')).rejects.toMatchObject({ status, retryAfterMs: 19_000 });
+ });
+
+ it.each(['<html>Login</html>', '{}', 'null'])('rejects an unexpected successful usage body', async body => {
+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response(body));
+ await expect(new PlugskyProvider().validateKey('test-key')).rejects.toMatchObject({ status: 502 });
+ });
+
+ it('preserves chat, JSON mode, token usage and route attribution', async () => {
+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(json({
+ id: 'test', object: 'chat.completion', created: 1, model,
+ choices: [{ index: 0, message: { role: 'assistant', content: '{"ok":true}' }, finish_reason: 'stop' }],
+ usage: { prompt_tokens: 5, completion_tokens: 4, total_tokens: 9 },
+ }));
+ const result = await new PlugskyProvider().chatCompletion('test-key', [{ role: 'user', content: 'JSON please' }], model,
+ { max_tokens: 64, temperature: 0.2, response_format: { type: 'json_object' } });
+ expect(fetch.mock.calls[0][0]).toBe(`${PLUGSKY_BASE_URL}/chat/completions`);
+ expect(JSON.parse(String(fetch.mock.calls[0][1]?.body))).toMatchObject({ model, max_tokens: 64, temperature: 0.2, response_format: { type: 'json_object' } });
+ expect(result.choices[0].message.content).toBe('{"ok":true}');
+ expect(result.usage?.total_tokens).toBe(9);
+ expect(result._routed_via).toEqual({ platform: 'plugsky', model });
+ });
+
+ it('streams SSE content and preserves usage', async () => {
+ const frames = [
+ { id: 's', object: 'chat.completion.chunk', created: 1, model: 'upstream-model', choices: [{ index: 0, delta: { content: 'OK' }, finish_reason: null }] },
+ { id: 's', object: 'chat.completion.chunk', created: 1, model: 'upstream-model', choices: [{ index: 0, delta: {}, finish_reason: 'stop' }], usage: { prompt_tokens: 3, completion_tokens: 1, total_tokens: 4 } },
+ ];
+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response(frames.map(x => `data: ${JSON.stringify(x)}\n\n`).join('') + 'data: [DONE]\n\n'));
+ const chunks = [];
+ for await (const chunk of new PlugskyProvider().streamChatCompletion('test-key', [{ role: 'user', content: 'Hi' }], model)) chunks.push(chunk);
+ expect(chunks.map(c => c.choices[0]?.delta.content ?? '').join('')).toBe('OK');
+ expect(chunks.find(c => c.usage)?.usage?.total_tokens).toBe(4);
+ // Live SSE identifies the backing upstream, unlike non-streaming aliases.
+ expect(chunks[0].model).toBe('upstream-model');
+ });
+
+ it('preserves chat rate limits and Retry-After', async () => {
+ vi.spyOn(global, 'fetch').mockResolvedValue(json({ error: { message: 'Rate limited' } }, 429, { 'Retry-After': '12' }));
+ await expect(new PlugskyProvider().chatCompletion('test-key', [], model)).rejects.toMatchObject({ status: 429, retryAfterMs: 12_000 });
+ });
+});
diff --git a/server/src/__tests__/routes/keys-providers-checklist.test.ts b/server/src/__tests__/routes/keys-providers-checklist.test.ts
index d170a665..9e335ee8 100644
--- a/server/src/__tests__/routes/keys-providers-checklist.test.ts
+++ b/server/src/__tests__/routes/keys-providers-checklist.test.ts
@@ -59,6 +59,8 @@ describe('GET /api/keys/providers — provider checklist (#543)', () => {
.toMatchObject({ platform: 'llmtr', name: 'LLMTR', configured: false, keyless: false });
expect(body.providers.find((p: { platform: string }) => p.platform === 'typhoon'))
.toMatchObject({ platform: 'typhoon', name: 'Typhoon', configured: false, keyless: false });
+ expect(body.providers.find((p: { platform: string }) => p.platform === 'plugsky'))
+ .toMatchObject({ platform: 'plugsky', name: 'Plugsky', configured: false, keyless: false });
for (const [platform, name] of [['gizmo', 'Gizmo'], ['blockrun', 'BlockRun']]) {
expect(body.providers.find((p: { platform: string }) => p.platform === platform))
.toMatchObject({ platform, name, configured: false, keyless: false });
diff --git a/server/src/__tests__/services/electronhub-speech.test.ts b/server/src/__tests__/services/electronhub-speech.test.ts
new file mode 100644
index 00000000..f3b8366b
--- /dev/null
+++ b/server/src/__tests__/services/electronhub-speech.test.ts
@@ -0,0 +1,84 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { initDb, getDb } from '../../db/index.js';
+import { encrypt } from '../../lib/crypto.js';
+import { MEDIA_PLATFORMS, runSpeech } from '../../services/media.js';
+import { applyCatalog } from '../../services/catalog-sync.js';
+import { isBuiltinDiscoveryEligible } from '../../services/builtin-model-discovery.js';
+
+const models = ['gemini-3.8-flash-tts', 'gemini-3.8-flash-lite-tts', 'humain-tts'];
+const wav = Buffer.alloc(48);
+wav.write('RIFF', 0); wav.writeUInt32LE(40, 4); wav.write('WAVE', 8);
+wav.write('fmt ', 12); wav.writeUInt32LE(16, 16); wav.writeUInt16LE(1, 20);
+wav.writeUInt16LE(1, 22); wav.writeUInt32LE(24000, 24); wav.writeUInt32LE(48000, 28);
+wav.writeUInt16LE(2, 32); wav.writeUInt16LE(16, 34); wav.write('data', 36); wav.writeUInt32LE(4, 40);
+const mp3 = Buffer.concat([Buffer.from('ID3'), Buffer.alloc(24)]);
+
+function seed() {
+ const db = getDb(), secret = encrypt('electronhub-test-key');
+ db.prepare("INSERT INTO api_keys (platform,label,encrypted_key,iv,auth_tag,status,enabled) VALUES ('electronhub','test',?,?,?,'healthy',1)")
+ .run(secret.encrypted, secret.iv, secret.authTag);
+ models.forEach((model, i) => db.prepare("INSERT INTO media_models (platform,model_id,display_name,modality,priority,enabled) VALUES ('electronhub',?,?,'audio',?,1)").run(model, model, i));
+}
+
+describe('ElectronHub speech and Plugsky catalog integration', () => {
+ beforeEach(() => { process.env.ENCRYPTION_KEY = '0'.repeat(64); initDb(':memory:'); });
+ afterEach(() => vi.restoreAllMocks());
+
+ it.each(models)('routes %s to speech with a compatible default voice', async model => {
+ seed();
+ const audio = model === 'humain-tts' ? mp3 : wav;
+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(audio, { headers: { 'content-type': 'application/octet-stream' } }));
+ const result = await runSpeech(model, { input: 'Hello', voice: 'alloy' });
+ expect(result).toMatchObject({ platform: 'electronhub', modelId: model, audio, contentType: model === 'humain-tts' ? 'audio/mpeg' : 'audio/wav' });
+ const [url, init] = fetch.mock.calls[0];
+ expect(url).toBe('https://api.electronhub.ai/v1/audio/speech');
+ expect(new Headers(init?.headers).get('authorization')).toBe('Bearer electronhub-test-key');
+ expect(JSON.parse(String(init?.body))).toEqual({ model, input: 'Hello', voice: model === 'humain-tts' ? 'sara' : 'Kore', response_format: 'mp3' });
+ });
+
+ it('forwards an explicit voice and format, and detects actual audio instead of trusting MIME', async () => {
+ seed();
+ const fetch = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(wav, { headers: { 'content-type': 'audio/mpeg' } }));
+ expect((await runSpeech(models[0], { input: 'Hi', voice: 'Puck', format: 'wav' })).contentType).toBe('audio/wav');
+ expect(JSON.parse(String(fetch.mock.calls[0][1]?.body))).toMatchObject({ voice: 'Puck', response_format: 'wav' });
+ });
+
+ it.each(['', '{"error":"private upstream details"}', '<html>Error</html>', 'RIFFnot audio'])('rejects empty or non-audio HTTP 200 bodies without echoing them', async body => {
+ seed();
+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response(body, { headers: { 'content-type': 'audio/mpeg' } }));
+ await expect(runSpeech(models[0], { input: 'Hi' })).rejects.toMatchObject({ status: 502 });
+ expect((getDb().prepare("SELECT error FROM requests WHERE request_type='audio'").get() as { error: string }).error).not.toContain('private upstream details');
+ });
+
+ it('rejects unimplemented raw PCM before calling upstream', async () => {
+ seed();
+ const fetch = vi.spyOn(global, 'fetch');
+ await expect(runSpeech(models[0], { input: 'Hi', format: 'pcm' })).rejects.toMatchObject({ status: 400 });
+ expect(fetch).not.toHaveBeenCalled();
+ });
+
+ it('preserves rate-limit retry hints', async () => {
+ seed();
+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response('Rate limited', { status: 429, headers: { 'Retry-After': '30' } }));
+ await expect(runSpeech(models[0], { input: 'Hi' })).rejects.toMatchObject({ status: 429, retryAfterMs: 30_000 });
+ });
+
+ it('has no Plugsky seeds or automatic discovery; ingests chat and speech separately', () => {
+ const db = getDb();
+ expect(MEDIA_PLATFORMS.has('electronhub')).toBe(true);
+ expect(db.prepare("SELECT COUNT(*) AS n FROM models WHERE platform='plugsky'").get()).toEqual({ n: 0 });
+ expect(isBuiltinDiscoveryEligible(db, 'plugsky')).toBe(false);
+ const row = (platform: string, modelId: string) => ({ platform, modelId, displayName: modelId, intelligenceRank: 50, speedRank: 50, sizeLabel: '', limits: { rpm: null, rpd: null, tpm: null, tpd: null }, monthlyTokenBudget: 'Shared free quota', contextWindow: 131072, enabled: true, supportsVision: false, supportsTools: false });
+ const counts = applyCatalog(db, {
+ version: '2099.01.01', generatedAt: new Date().toISOString(), tier: 'live', quirks: [],
+ models: [
+ ...['plugsky-micro', 'plugsky-lite'].map(id => row('plugsky', id)),
+ ...models.map(id => ({ ...row('electronhub', id), modality: 'audio' as const })),
+ ],
+ });
+ expect(counts.skippedUnknownPlatform).toBe(0);
+ expect(db.prepare("SELECT model_id FROM models WHERE platform='plugsky' ORDER BY model_id").all()).toEqual([{ model_id: 'plugsky-lite' }, { model_id: 'plugsky-micro' }]);
+ expect(db.prepare("SELECT COUNT(*) AS n FROM models WHERE platform='electronhub' AND model_id LIKE '%tts'").get()).toEqual({ n: 0 });
+ expect(db.prepare("SELECT model_id,modality FROM media_models WHERE platform='electronhub' ORDER BY model_id").all()).toEqual(models.map(model_id => ({ model_id, modality: 'audio' })).sort((a, b) => a.model_id.localeCompare(b.model_id)));
+ });
+});
diff --git a/server/src/__tests__/services/provider-quota.test.ts b/server/src/__tests__/services/provider-quota.test.ts
index d640ed3e..8fcfe35a 100644
--- a/server/src/__tests__/services/provider-quota.test.ts
+++ b/server/src/__tests__/services/provider-quota.test.ts
@@ -52,6 +52,7 @@ describe('provider-quota: pool inference', () => {
for (const model of ['first-model', 'another-model']) {
expect(inferQuotaPoolKey('aclide', model)).toBe('aclide::monthly-credit');
expect(inferQuotaPoolKey('speka', model)).toBe('speka::monthly-credit');
+ expect(inferQuotaPoolKey('plugsky', model)).toBe('plugsky::fair-use');
expect(inferQuotaPoolKey('clod', model)).toBe('clod::daily-free');
expect(inferQuotaPoolKey('blaze', model)).toBe('blaze::daily-free');
expect(inferQuotaPoolKey('speechify', model)).toBe('speechify::monthly-characters');
diff --git a/server/src/lib/key-parser.ts b/server/src/lib/key-parser.ts
index 85975ff0..0d326e22 100644
--- a/server/src/lib/key-parser.ts
+++ b/server/src/lib/key-parser.ts
@@ -47,6 +47,7 @@ export const PREFIX_MAP: Record<string, string> = {
ACLIDE_: 'aclide',
SPEKA_: 'speka',
TYPHOON_: 'typhoon',
+ PLUGSKY_: 'plugsky',
OPENTYPHOON_: 'typhoon',
OPEN_TYPHOON_: 'typhoon',
LLMTR_: 'llmtr',
@@ -149,6 +150,7 @@ export const AUTH_JSON_PROVIDER_MAP: Record<string, string> = {
aclide: 'aclide',
speka: 'speka',
typhoon: 'typhoon',
+ plugsky: 'plugsky',
opentyphoon: 'typhoon',
'open-typhoon': 'typhoon',
llmtr: 'llmtr',
diff --git a/server/src/providers/electronhub.ts b/server/src/providers/electronhub.ts
index 1036b539..a362df0f 100644
--- a/server/src/providers/electronhub.ts
+++ b/server/src/providers/electronhub.ts
@@ -4,6 +4,8 @@ import type { QuotaObservationContext } from '../services/provider-quota.js';
import { contentToString } from '../lib/content.js';
import { OpenAICompatProvider } from './openai-compat.js';
+export const ELECTRONHUB_BASE_URL = 'https://api.electronhub.ai/v1';
+
// 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 ';
@@ -18,10 +20,10 @@ export class ElectronHubProvider extends OpenAICompatProvider {
super({
platform: 'electronhub',
name: 'ElectronHub',
- baseUrl: 'https://api.electronhub.ai/v1',
+ baseUrl: ELECTRONHUB_BASE_URL,
// /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',
+ validateUrl: `${ELECTRONHUB_BASE_URL}/user/me`,
timeoutMs: 90_000,
});
}
diff --git a/server/src/providers/index.ts b/server/src/providers/index.ts
index 0110a310..5d8dfcd2 100644
--- a/server/src/providers/index.ts
+++ b/server/src/providers/index.ts
@@ -12,6 +12,7 @@ import { SailProvider } from './sail.js';
import { AclideProvider } from './aclide.js';
import { SpekaProvider } from './speka.js';
import { TyphoonProvider } from './typhoon.js';
+import { PlugskyProvider } from './plugsky.js';
import { LlmtrProvider } from './llmtr.js';
import { GizmoProvider } from './gizmo.js';
import { BlockRunProvider } from './blockrun.js';
@@ -64,6 +65,7 @@ register(new SailProvider());
register(new AclideProvider());
register(new SpekaProvider());
register(new TyphoonProvider());
+register(new PlugskyProvider());
register(new LlmtrProvider());
register(new GizmoProvider());
register(new BlockRunProvider());
diff --git a/server/src/providers/plugsky.ts b/server/src/providers/plugsky.ts
new file mode 100644
index 00000000..d97633c0
--- /dev/null
+++ b/server/src/providers/plugsky.ts
@@ -0,0 +1,28 @@
+import { providerHttpError, type KeyValidationResult } from './base.js';
+import { OpenAICompatProvider } from './openai-compat.js';
+
+export const PLUGSKY_BASE_URL = 'https://plugsky.com/v1';
+
+/** Permanent free chat aliases are catalog-managed. Do not discover the whole
+ * public roster: it also includes paid and seven-day trial models. */
+export class PlugskyProvider extends OpenAICompatProvider {
+ constructor() {
+ super({
+ platform: 'plugsky', name: 'Plugsky', baseUrl: PLUGSKY_BASE_URL,
+ // /models is public; this read-only endpoint requires a real API key.
+ validateUrl: `${PLUGSKY_BASE_URL}/plugsky/usage`,
+ });
+ }
+
+ protected override async validationResult(response: Response): Promise<KeyValidationResult> {
+ if ([401, 403].includes(response.status)) return super.validationResult(response);
+ if (!response.ok) {
+ throw providerHttpError(response, 'Plugsky key validation is temporarily inconclusive');
+ }
+ const body = await response.json().catch(() => null) as { data?: unknown } | null;
+ if (!body || !Array.isArray(body.data)) {
+ throw Object.assign(new Error('Plugsky returned an invalid usage response'), { status: 502 });
+ }
+ return true;
+ }
+}
diff --git a/server/src/routes/keys.ts b/server/src/routes/keys.ts
index 41809223..57fac161 100644
--- a/server/src/routes/keys.ts
+++ b/server/src/routes/keys.ts
@@ -45,6 +45,7 @@ const PLATFORMS = [
'aclide',
'speka',
'typhoon',
+ 'plugsky',
'llmtr',
'gizmo',
'blockrun',
diff --git a/server/src/services/media.ts b/server/src/services/media.ts
index 93ace331..e2af8fab 100644
--- a/server/src/services/media.ts
+++ b/server/src/services/media.ts
@@ -19,10 +19,11 @@ import { assessProviderUrl } from '../lib/url-guard.js';
import { isOnCooldown, setCooldown } from './ratelimit.js';
import { SPEECHIFY_BASE_URL, SPEECHIFY_VERSION } from '../providers/speechify.js';
import { TYPHOON_BASE_URL } from '../providers/typhoon.js';
+import { ELECTRONHUB_BASE_URL } from '../providers/electronhub.js';
/** Platforms with a media adapter below. catalog-sync gates media rows on this
* (decoupled from the chat provider registry — e.g. SiliconFlow is media-only). */
-export const MEDIA_PLATFORMS = new Set(['nvidia', 'pollinations', 'cloudflare', 'siliconflow', 'google', 'speechify']);
+export const MEDIA_PLATFORMS = new Set(['nvidia', 'pollinations', 'cloudflare', 'siliconflow', 'google', 'speechify', 'electronhub']);
/** Video uses a dedicated optional catalog registry so binaries that predate
* this modality ignore the rows instead of accidentally ingesting them as
@@ -616,6 +617,30 @@ async function callSpeechProvider(
if (j.audio_format !== fmt) throw new MediaError('Speechify returned a different audio format', 502);
return { audio: Buffer.from(b64, 'base64'), contentType: fmt === 'ogg' ? 'audio/ogg' : contentTypeFor(fmt) };
}
+ case 'electronhub': {
+ // Only the container formats exercised by this adapter are supported.
+ // Gemini TTS may return WAV even for response_format=mp3. Detect the
+ // actual bytes instead of labelling WAV as MP3 or accepting a JSON error.
+ const format = p.format ?? 'mp3';
+ if (!['mp3', 'wav'].includes(format)) {
+ throw new MediaError('ElectronHub speech supports mp3 and wav output through this adapter', 400);
+ }
+ const defaultVoice = row.model_id === 'humain-tts' ? 'sara'
+ : row.model_id.startsWith('gemini-') ? 'Kore' : 'alloy';
+ const voice = !p.voice || p.voice === 'alloy' ? defaultVoice : p.voice;
+ const r = await mediaFetch(`${ELECTRONHUB_BASE_URL}/audio/speech`, 'electronhub', 'audio', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...bearerAuthHeader(key) },
+ body: JSON.stringify({ model: row.model_id, input: p.input, voice, response_format: format }),
+ });
+ const audio = Buffer.from(await r.arrayBuffer());
+ const wav = audio.length > 44 && audio.toString('ascii', 0, 4) === 'RIFF'
+ && audio.toString('ascii', 8, 12) === 'WAVE';
+ const mp3 = audio.length > 10 && (audio.toString('ascii', 0, 3) === 'ID3'
+ || (audio[0] === 0xff && (audio[1] & 0xe0) === 0xe0 && (audio[1] & 0x06) !== 0));
+ if (!wav && !mp3) throw new MediaError('ElectronHub returned no recognized speech audio', 502);
+ return { audio, contentType: wav ? 'audio/wav' : 'audio/mpeg' };
+ }
case 'custom': {
if (!credential.baseUrl) throw new MediaError('custom audio provider is missing base_url', 500);
const fmt = p.format ?? 'mp3';
diff --git a/server/src/services/provider-quota.ts b/server/src/services/provider-quota.ts
index fe7d9fb2..821a6427 100644
--- a/server/src/services/provider-quota.ts
+++ b/server/src/services/provider-quota.ts
@@ -118,6 +118,7 @@ export function inferPoolForPlatform(platform: Platform, modelId?: string | null
if (platform === 'sail') return 'sail::monthly-credit';
if (platform === 'aclide') return 'aclide::monthly-credit';
if (platform === 'speka') return 'speka::monthly-credit';
+ if (platform === 'plugsky') return 'plugsky::fair-use';
if (platform === 'electronhub') return normalizedModelId.endsWith(':free') ? 'electronhub::daily-free' : 'electronhub::weekly-credit';
if (platform === 'experiential') return 'experiential::monthly-credit';
if (platform === 'router9') return 'router9::monthly-credit';
@@ -180,6 +181,7 @@ export function inferPoolForPlatform(platform: Platform, modelId?: string | null
function isSharedPool(platform: Platform): boolean {
if (platform === 'aclide') return true;
if (platform === 'speka') return true;
+ if (platform === 'plugsky') return true;
if (['electronhub', 'experiential', 'router9', 'septor', 'clod', 'speechify', 'blaze', 'lucidity', 'airforce', 'dreamprompting', 'waterfall', 'logfare'].includes(platform)) 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);
}
diff --git a/shared/types.ts b/shared/types.ts
index f1b8e662..dfb39b11 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -74,6 +74,8 @@ export type Platform =
| 'speka'
// Ongoing free research API for chat and speech recognition; catalog only.
| 'typhoon'
+ // Permanent free chat aliases, shared fair-use quota; signed catalog only.
+ | 'plugsky'
// Selected zero-priced routes have daily/rolling quotas without a top-up;
// signed catalog only. The public roster also includes paid/promotional IDs.
| 'llmtr'