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

fix(freeai): skip unverifiable credential health probes (#1540)

Vladislave6cee44df58e
diff --git a/docs/providers/freeai.md b/docs/providers/freeai.md
index c26d9086..02f5aa91 100644
--- a/docs/providers/freeai.md
+++ b/docs/providers/freeai.md
@@ -26,10 +26,11 @@ the provider's account history before retrying a queued request.
Live controls on 2026-10-11 found that the model roster, invalid-payload errors,
invalid-model errors **and even a successful Kokoro synthesis** returned the same
status for valid and bogus credentials. Those endpoints cannot prove that a key
-is valid. Automatic health validation therefore stays inconclusive and spends no
-quota. Existing health behavior preserves the key's unknown/healthy status, so
-configured keys remain usable for inference. The supplied key is still sent on
-actual generation requests; this integration does not advertise anonymous access.
+is valid. Automatic health checks therefore skip credential validation entirely without
+spending quota or recording a misleading validation error. Existing `unknown`
+and `healthy` key states remain usable for inference; their status is not proof
+that the credential is valid. The supplied key is still sent on actual
+generation requests; this integration does not advertise anonymous access.
Kokoro generated valid WAV files during live testing. Two tested Qwen aliases
returned the same backend identity under conflicting advertised names; the other
diff --git a/server/src/__tests__/providers/freeai.test.ts b/server/src/__tests__/providers/freeai.test.ts
index 81064658..8143bf14 100644
--- a/server/src/__tests__/providers/freeai.test.ts
+++ b/server/src/__tests__/providers/freeai.test.ts
@@ -14,6 +14,7 @@ describe('Free.ai', () => {
expect(hasProvider('freeai')).toBe(true);
const fetch = vi.spyOn(globalThis, 'fetch');
const provider = new FreeAiProvider();
+ expect(provider.supportsKeyValidation).toBe(false);
await expect(provider.chatCompletion()).rejects.toMatchObject({ status: 400 });
await expect(provider.streamChatCompletion().next()).rejects.toMatchObject({ status: 400 });
await expect(provider.validateKey('')).resolves.toMatchObject({ valid: false });
@@ -29,16 +30,18 @@ describe('Free.ai', () => {
expect(fetch).not.toHaveBeenCalled();
});
- it('keeps an unverified configured key routable during health checks without falsely validating it', async () => {
+ it('skips unverifiable health probes, clears old errors and keeps the key routable', async () => {
process.env.ENCRYPTION_KEY = '0'.repeat(64);
initDb(':memory:');
const { encrypted, iv, authTag } = encrypt('test-key');
- const id = Number(getDb().prepare("INSERT INTO api_keys (platform,label,encrypted_key,iv,auth_tag,status,enabled) VALUES ('freeai','test',?,?,?,'unknown',1)").run(encrypted, iv, authTag).lastInsertRowid);
+ const id = Number(getDb().prepare("INSERT INTO api_keys (platform,label,encrypted_key,iv,auth_tag,status,enabled,last_health_error) VALUES ('freeai','test',?,?,?,'unknown',1,'stale validation error')").run(encrypted, iv, authTag).lastInsertRowid);
const fetch = vi.spyOn(globalThis, 'fetch');
+ const validate = vi.spyOn(FreeAiProvider.prototype, 'validateKey');
await expect(checkKeyHealth(id)).resolves.toBe('unknown');
expect(getDb().prepare('SELECT status, enabled, last_health_error FROM api_keys WHERE id=?').get(id)).toMatchObject({
- status: 'unknown', enabled: 1, last_health_error: expect.stringContaining('key validity is unknown'),
+ status: 'unknown', enabled: 1, last_health_error: null,
});
+ expect(validate).not.toHaveBeenCalled();
expect(fetch).not.toHaveBeenCalled();
});
diff --git a/server/src/providers/freeai.ts b/server/src/providers/freeai.ts
index 3f08e28a..bbafd357 100644
--- a/server/src/providers/freeai.ts
+++ b/server/src/providers/freeai.ts
@@ -20,6 +20,13 @@ export function freeAiAudioUrl(body: unknown): string | null {
export class FreeAiProvider extends BaseProvider {
readonly platform = 'freeai' as const;
readonly name = 'Free.ai';
+
+ // No published endpoint distinguishes genuine from bogus keys. Skip
+ // scheduled health probes instead of persisting an inconclusive error.
+ override get supportsKeyValidation(): boolean {
+ return false;
+ }
+
async validateKey(apiKey: string): Promise<KeyValidationResult> {
if (!apiKey.trim()) return { valid: false, error: 'Free.ai API key is required' };
// Live controls (2026-10-11): /models, invalid-model errors and even Kokoro